Extra unit test for Issue 16

This commit is contained in:
joseph.lizier 2013-07-06 18:36:03 +00:00
parent 68b0233e28
commit 1c0e9098cc
1 changed files with 23 additions and 0 deletions

View File

@ -116,4 +116,27 @@ public class ConditionalMutualInfoMultiVariateTester extends
}
/**
* Test whether, if the conditional variable has zero covariance,
* that the method just returns the MI
*
* @throws Exception
*/
public void testZeroCovarianceConditional() throws Exception {
ConditionalMutualInfoCalculatorMultiVariateGaussian condMiCalc =
new ConditionalMutualInfoCalculatorMultiVariateGaussian();
condMiCalc.initialise(1, 1, 1);
double covar1 = 1;
double covar2 = 0.8;
double crossCovar = 0.6;
double[][] covariance = new double[][] {
{covar1, crossCovar, 0.0},
{crossCovar, covar2, 0.0},
{0.0, 0.0, 0.0}};
condMiCalc.setCovariance(covariance, false);
double condMi = condMiCalc.computeAverageLocalOfObservations();
assertEquals(0.5 * Math.log(covar1 * covar2 / (covar1 * covar2 - crossCovar*crossCovar)),
condMi, 0.0000000001);
}
}