Home > Mateda2.0 > learning > FindMargProb.m

# FindMargProb

## PURPOSE

[UnivProb,BivProb]=FindMargProb(SelPop,NumbVar,Card)

## SYNOPSIS

function[UnivProb,BivProb]=FindMargProb(SelPop,NumbVar,Card)

## DESCRIPTION

     [UnivProb,BivProb]=FindMargProb(SelPop,NumbVar,Card)
     FindMargProb:      Computes the univariate and bivariate marginal probabilities
     INPUT:
     SelPop: Selected population
     NumbVar: Number of variables
     Card: Vector with the dimension of all the variables.
     OUTPUT:
     UnivProb:  Univariate probabilities
     BivProb:  Bivariate probabilities
     Last version 8/26/2008. Roberto Santana and Siddarta Shakya (roberto.santana@ehu.es)

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- LearnMOAModel [model] = LearnMOAModel(k,NumbVar,Card,SelPop,AuxFunVal,learning_params)
- LearnMargProdModel [model] = LearnMargProdModel(k,NumbVar,Card,SelPop,AuxFunVal,learning_params)
- LearnTreeModel [model] = LearnTreeModel(k,NumbVar,Card,SelPop,AuxFunVal,learning_params)

## SOURCE CODE

    0001 function[UnivProb,BivProb]=FindMargProb(SelPop,NumbVar,Card)
    0002 % [UnivProb,BivProb]=FindMargProb(SelPop,NumbVar,Card)
    0003 % FindMargProb:      Computes the univariate and bivariate marginal probabilities
    0004 % INPUT:
    0005 % SelPop: Selected population
    0006 % NumbVar: Number of variables
    0007 % Card: Vector with the dimension of all the variables.
    0008 % OUTPUT:
    0009 % UnivProb:  Univariate probabilities
    0010 % BivProb:  Bivariate probabilities
    0011 % Last version 8/26/2008. Roberto Santana and Siddarta Shakya (roberto.santana@ehu.es)
    0012
    0013 SelPopSize = size(SelPop,1);
    0014 for i=1:NumbVar-1,
    0015  UnivProb{i} = zeros(1,Card(i));   %Initialization of univariate probabilities
    0016  if (i==NumbVar-1)
    0017     UnivProb{NumbVar} = zeros(1,Card(NumbVar));
    0018  end,
    0019  for j=i+1:NumbVar,
    0020    BivProb{i,j} = zeros(1,Card(i)*Card(j));  %Initialization of bivariate probabilities for all pair of variables are computed
    0021    for k=1:SelPopSize,
    0022      if(j==i+1)
    0023         UnivProb{i}(SelPop(k,i)+1) = UnivProb{i}(SelPop(k,i)+1) + 1;
    0024         if(i==NumbVar-1)
    0025           UnivProb{NumbVar}(SelPop(k,NumbVar)+1) = UnivProb{NumbVar}(SelPop(k,NumbVar)+1) + 1;
    0026         end
    0027      end
    0028      BivProb{i,j}(Card(j)*SelPop(k,i) + SelPop(k,j)+1) = BivProb{i,j}(Card(j)*SelPop(k,i) + SelPop(k,j)+1) +1;
    0029    end,
    0030   BivProb{i,j} = BivProb{i,j}/sum(BivProb{i,j}); % Normalization of the probabilities
    0031  end
    0032  UnivProb{i} = UnivProb{i}/sum(UnivProb{i});
    0033 end
    0034 UnivProb{NumbVar} = UnivProb{NumbVar}/sum(UnivProb{NumbVar});
    0035
    0036