Home > Mateda2.0 > otherfiles > IntMutualInfFromMargProb.m

# IntMutualInfFromMargProb

## PURPOSE

[MI]=IntMutualInfFromMargProb(NumbVar,Card,UnivProb,BivProb)

## SYNOPSIS

function[MI]=IntMutualInfFromMargProb(NumbVar,Card,UnivProb,BivProb)

## DESCRIPTION

     [MI]=IntMutualInfFromMargProb(NumbVar,Card,UnivProb,BivProb)
     IntMutualInfFromMargProb:   This functions computes the normalized matrix of mutual information (MI)
                                 from the sets of univariate and bivariate marginal probabilities
     INPUTS:
     NumbVar: Number of variables
     Card: Vector with the dimension of all the variables.
     UnivProb: Univariate probabilities
     BivProb: Bivariate probalities
     OUTPUTS:
     MI: Matrix of mutual information

     Last version 8/26/2008. Roberto Santana (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[MI]=IntMutualInfFromMargProb(NumbVar,Card,UnivProb,BivProb)
    0002 % [MI]=IntMutualInfFromMargProb(NumbVar,Card,UnivProb,BivProb)
    0003 % IntMutualInfFromMargProb:   This functions computes the normalized matrix of mutual information (MI)
    0004 %                             from the sets of univariate and bivariate marginal probabilities
    0005 % INPUTS:
    0006 % NumbVar: Number of variables
    0007 % Card: Vector with the dimension of all the variables.
    0008 % UnivProb: Univariate probabilities
    0009 % BivProb: Bivariate probalities
    0010 % OUTPUTS:
    0011 % MI: Matrix of mutual information
    0012 %
    0013 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
    0014
    0015 MI = zeros(NumbVar);
    0016 for i=1:NumbVar-1,
    0017  for j=i+1:NumbVar,
    0018    for k=0:Card(i)-1,
    0019       for l=0:Card(j)-1,
    0020         if(BivProb{i,j}(Card(j)*k+l+1)>0)
    0021             MI(i,j) = MI(i,j) + BivProb{i,j}(Card(j)*k+l+1)* log(BivProb{i,j}(Card(j)*k+l+1)/(UnivProb{i}(k+1)*UnivProb{j}(l+1)));
    0022         end
    0023       end,
    0024    end,
    0025    MI(i,j) = MI(i,j)/(Card(i)*Card(j)); %Normalization of the mutual information
    0026    MI(j,i) = MI(i,j);
    0027  end,
    0028 end,