Home > Mateda2.0 > otherfiles > IntMutualInf.m

IntMutualInf

PURPOSE ^

[MI]=IntMutualInf(SelPop,NumbVar,N,Card)

SYNOPSIS ^

function[MI]=IntMutualInf(SelPop,NumbVar,N,Card)

DESCRIPTION ^

 [MI]=IntMutualInf(SelPop,NumbVar,N,Card)
 IntMutualInf computes the normalized matrix of mutual information (MI)
 from a discrete data set. MI should be normalized because variables may have different
 cardinalities
 INPUTS: 
 SelPop: Selected population 
 NumbVar: Number of variables
 N: Size of the selected population
 Card: Cardinality of the variables. 
 OUTPUT:
 MI: Matrix of normalized mutual information
 
 Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function[MI]=IntMutualInf(SelPop,NumbVar,N,Card)
0002 % [MI]=IntMutualInf(SelPop,NumbVar,N,Card)
0003 % IntMutualInf computes the normalized matrix of mutual information (MI)
0004 % from a discrete data set. MI should be normalized because variables may have different
0005 % cardinalities
0006 % INPUTS:
0007 % SelPop: Selected population
0008 % NumbVar: Number of variables
0009 % N: Size of the selected population
0010 % Card: Cardinality of the variables.
0011 % OUTPUT:
0012 % MI: Matrix of normalized mutual information
0013 %
0014 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
0015 
0016 for i=1:NumbVar-1,
0017  UnivProb{i} = zeros(1,Card(i));   %Initialization of univariate probabilities
0018  if (i==NumbVar-1)
0019     UnivProb{NumbVar} = zeros(1,Card(NumbVar));
0020  end,
0021  for j=i+1:NumbVar,
0022    BivProb{i,j} = zeros(1,Card(i)*Card(j));  %Initialization of bivariate probabilities for all pair of variables are computed
0023    for k=1:N,
0024      if(j==i+1)
0025         UnivProb{i}(SelPop(k,i)+1) = UnivProb{i}(SelPop(k,i)+1) + 1;
0026         if(i==NumbVar-1)
0027           UnivProb{NumbVar}(SelPop(k,NumbVar)+1) = UnivProb{NumbVar}(SelPop(k,NumbVar)+1) + 1;
0028         end
0029      end
0030      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;
0031    end,
0032   BivProb{i,j} = BivProb{i,j}/sum(BivProb{i,j}); % Normalization of the probabilities
0033  end
0034  UnivProb{i} = UnivProb{i}/sum(UnivProb{i});
0035 end 
0036 UnivProb{NumbVar} = UnivProb{NumbVar}/sum(UnivProb{NumbVar});
0037 
0038 MI = zeros(NumbVar);
0039 for i=1:NumbVar-1,
0040  for j=i+1:NumbVar,
0041    for k=0:Card(i)-1,
0042       for l=0:Card(j)-1,
0043         if(BivProb{i,j}>0)
0044             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)));
0045         end
0046       end,
0047    end,
0048    MI(i,j) = MI(i,j)/(Card(i)*Card(j)); %Normalization of the mutual information
0049    MI(j,i) = MI(i,j);
0050  end,
0051 end,

Generated on Fri 04-Dec-2009 13:38:29 by m2html © 2003