a set of C++ library classes
for neural networks development



class MutualInfo2

Class for evaluating mutual information between two random variables
Random variables are discretized dividing their range values in bins.

Inheritance:


Public Methods

[more] MutualInfo2 (unsigned num_data, unsigned num_bins, float** thedata, float min_v = MIN_VALUE, float max_v = MAX_VALUE)
Constructor.
[more] MutualInfo2 (unsigned num_data, unsigned num_bins, char* f, unsigned first, unsigned second, float min_v = MIN_VALUE, float max_v = MAX_VALUE)
Constructor.
[more] ~MutualInfo2 ()
Destroyer
[more]void printdata (void)
printdata to stdout
[more]float Read_min ()
return minimum value of random variable
[more]float Read_max ()
return maximum value of random variable
[more]void Print_min ()
print on stdout minimum value of random variable
[more]void Print_max ()
print on stdout maximum value of random variable
[more]void Calc_p (void)
It calculates the frequency of the single random variables.
[more]void Calc_Pjoint (void)
It calculates the joint frequency of the random variables.
[more]void Print_p (void)
print the matrix p
[more]void Print_Pjoint (void)
print the matrix Pjoint
[more]float* Calc_Entropy (void)
It calculates the entropy of the random variables.
[more]float* Read_Entropy (void)
Returns the entropy array of the random variables
[more]void Print_Entropy (void)
Print to stdout the entropy of the random variables
[more]float Calc_JointEntropy (void)
It calculates the joint entropy of the random variables.
[more]float Read_JointEntropy (void)
Returns the joint entropy of the random variables
[more]void Print_JointEntropy (void)
Print to stdout the joint entropy of the random variables
[more]float Calc_Minfo (void)
It calculates the mutual information of the random variables.
[more]float Read_Minfo (void)
Returns the mutual information of the random variables
[more]void Print_Minfo (void)
Print to stdout the mutual information of the random variables

Protected Fields

[more]static const float MIN_VALUE
Default minimum of the random variable value
[more]static const float MAX_VALUE
Default maximum of the random variable value
[more]float min
[more]float max
Maximum of the random variable value
[more]unsigned ndata
number of data values of each random variable
[more]unsigned nbins
number of bins
[more]float ampl
Amplitude of a single bin
[more]float** data
Matrix of values of the two random variables.
[more]float** p
matrix of values of frequencies of random variables; num rows = 2, num columns = nbins
[more]float** Pjoint
matrix of joint frequencies between the two variables; num rows = nbins, num columns = nbins
[more]float H [2]
Entropy of the two random variables;
[more]float Hjoint
Joint entropy of the two random variables
[more]float Minfo
Mutual information between variables

Protected Methods

[more]void builddata (unsigned num_data)
Builds data matrix
[more]int readdata (unsigned num_data, char* f, unsigned first, unsigned second)
Load random variables data from filef to array data.
[more]void buildp (unsigned num_bins)
It builds and initializes matrix of single frequecies p
[more]void buildPjoint (unsigned num_bins)
It builds and initializes matrix of joint frequencies
[more]virtual unsigned assignbin (unsigned num_var, unsigned num_data)
Calculate the bin of random variable num_var od the data[num_var][num_data].
[more]void Init_p (float init=0.0)
Initializes p
[more]void Init_Pjoint (float init=0.0)
Initializes Pjoint


Documentation

Class for evaluating mutual information between two random variables
Random variables are discretized dividing their range values in bins. For each bin is computed its frequency, both for each single variable and the joint frequency. Methods can be used to evaluate the entropy of each variable, the joint entropy, the conditional entropy and the mutual information.
ostatic const float MIN_VALUE
Default minimum of the random variable value

ostatic const float MAX_VALUE
Default maximum of the random variable value

ofloat min

ofloat max
Maximum of the random variable value

ounsigned ndata
number of data values of each random variable

ounsigned nbins
number of bins

ofloat ampl
Amplitude of a single bin

ofloat** data
Matrix of values of the two random variables. num rows = ndata, num columns = 2

ofloat** p
matrix of values of frequencies of random variables; num rows = 2, num columns = nbins

ofloat** Pjoint
matrix of joint frequencies between the two variables; num rows = nbins, num columns = nbins

ofloat H[2]
Entropy of the two random variables;

ofloat Hjoint
Joint entropy of the two random variables

ofloat Minfo
Mutual information between variables

ovoid builddata(unsigned num_data)
Builds data matrix

oint readdata(unsigned num_data, char* f, unsigned first, unsigned second)
Load random variables data from filef to array data.
First must be less than second
Parameters:
num_data - random variable values cardinality
f - file containing the values of random variables. This file must have columns corresponding to different variables separated by at least a blank.
- first the column in the file of the first variable. The columns are numbered from 1 to up.
second - the column in the file of the second variable. It must be greater than first

ovoid buildp(unsigned num_bins)
It builds and initializes matrix of single frequecies p

ovoid buildPjoint(unsigned num_bins)
It builds and initializes matrix of joint frequencies

ovirtual unsigned assignbin(unsigned num_var, unsigned num_data)
Calculate the bin of random variable num_var od the data[num_var][num_data]. It calaculates the index of the random variable num_var where the value data[num_var][num_data] falls. num_var is the row of p and the column of data. It corresponds also to the dimension of Pjoint.
Parameters:
num_var - index of the random variable in the matrix data
num_data - index of random variable value in data
Returns:
index number of the bin of p

ovoid Init_p(float init=0.0)
Initializes p

ovoid Init_Pjoint(float init=0.0)
Initializes Pjoint

o MutualInfo2(unsigned num_data, unsigned num_bins, float** thedata, float min_v = MIN_VALUE, float max_v = MAX_VALUE)
Constructor.
Parameters:
num_data - random variable values cardinality
num_bins - number of bins by wich each range of values of the random variables is subdivided
thedata - matrix of data. It must have two columns, each referring to a different random variables. The rows refer to the values of the random variables
min_v - Minimum of the random variable value
max_v - Maximum of the random variable value

o MutualInfo2(unsigned num_data, unsigned num_bins, char* f, unsigned first, unsigned second, float min_v = MIN_VALUE, float max_v = MAX_VALUE)
Constructor.
Parameters:
num_data - random variable values cardinality
num_bins - number of bins by wich each range of values of the random variables is subdivided
f - file containing the values of random variables. This file must have columns corresponding to different variables separated by at least a blank.
- first the column in the file of the first variable. The columns are numbered from 1 to up.
second - the column in the file of the second variable. It must be greater than first.
min_v - Minimum of the random variable value
max_v - Maximum of the random variable value

o ~MutualInfo2()
Destroyer

ovoid printdata(void)
printdata to stdout

ofloat Read_min()
return minimum value of random variable

ofloat Read_max()
return maximum value of random variable

ovoid Print_min()
print on stdout minimum value of random variable

ovoid Print_max()
print on stdout maximum value of random variable

ovoid Calc_p(void)
It calculates the frequency of the single random variables. The random variables are discretized in bins and for each bin is calculated the frequency considering the values of the array data.

ovoid Calc_Pjoint(void)
It calculates the joint frequency of the random variables. The random variables are discretized in bins and for each bin is calculated the frequency considering the values of the array data.

ovoid Print_p(void)
print the matrix p

ovoid Print_Pjoint(void)
print the matrix Pjoint

ofloat* Calc_Entropy(void)
It calculates the entropy of the random variables.
Returns:
the pointer to the variables entropy.

ofloat* Read_Entropy(void)
Returns the entropy array of the random variables

ovoid Print_Entropy(void)
Print to stdout the entropy of the random variables

ofloat Calc_JointEntropy(void)
It calculates the joint entropy of the random variables.
Returns:
joint entropy of the random variables.

ofloat Read_JointEntropy(void)
Returns the joint entropy of the random variables

ovoid Print_JointEntropy(void)
Print to stdout the joint entropy of the random variables

ofloat Calc_Minfo(void)
It calculates the mutual information of the random variables.
Returns:
mutual information of the random variables.

ofloat Read_Minfo(void)
Returns the mutual information of the random variables

ovoid Print_Minfo(void)
Print to stdout the mutual information of the random variables


Direct child classes:
MIError2

Alphabetic index HTML hierarchy of classes or Java


Last Updated February 2001
For comments and suggestions mail to Giorgio Valentini