Making local computation for CMI Gaussian calculator store the lastAverage if it was called with the previous observations

This commit is contained in:
Joseph Lizier 2019-05-17 22:47:16 +10:00
parent 681c9196ee
commit 1db8a2ac63
1 changed files with 14 additions and 4 deletions

View File

@ -737,6 +737,10 @@ public class ConditionalMutualInfoCalculatorMultiVariateGaussian
double[] localValues = new double[lengthOfReturnArray]; double[] localValues = new double[lengthOfReturnArray];
if (isPreviousObservations) {
lastAverage = 0;
}
for (int t = 0; t < newVar2Obs.length; t++) { for (int t = 0; t < newVar2Obs.length; t++) {
double[] var1DeviationsFromMean = double[] var1DeviationsFromMean =
@ -813,12 +817,18 @@ public class ConditionalMutualInfoCalculatorMultiVariateGaussian
localValues[t] -= analyticMeasDist.getMeanOfUncorrectedDistribution(); localValues[t] -= analyticMeasDist.getMeanOfUncorrectedDistribution();
} }
if (isPreviousObservations) {
lastAverage += localValues[t];
}
} }
// if (isPreviousObservations) { if (isPreviousObservations) {
// Don't store the average value here, since it won't be exactly // Originally we didn't store the average value here, worrying that it wouldn't be exactly
// the same as what would have been computed under the analytic expression // the same as what would have been computed under the analytic expression;
// } // however it should be, any difference is only numerical
lastAverage /= (double) newVar2Obs.length;
condMiComputed = true;
}
return localValues; return localValues;
} }