Removed unused function from KSG mixed.

This commit is contained in:
Pedro Martinez Mediano 2017-08-16 14:39:53 +01:00
parent 23bb573bb1
commit 2d42e6ebad
1 changed files with 0 additions and 86 deletions

View File

@ -485,92 +485,6 @@ public class MutualInfoCalculatorMultiVariateWithDiscreteKraskov implements Mutu
return mi;
}
/**
* This method correctly computes the average local MI, but recomputes the x and y
* distances between all tuples in time.
* Kept here for cases where we have too many observations
* to keep the norm between all pairs, and for testing purposes.
*
* @return
* @throws Exception
*/
public double computeAverageLocalOfObservationsWhileComputingDistances() throws Exception {
int N = continuousData.length; // number of observations
// Count the average number of points within eps_x and eps_y
double averageDiGammas = 0;
double avNx = 0;
double avNy = 0;
double testSum = 0.0; // Used for debugging prints
for (int t = 0; t < N; t++) {
// Compute eps_x and eps_y for this time step:
// First get x norms to all neighbours
// (note that norm of point t to itself will be set to infinity).
double[] norms = new double[N];
for (int t2 = 0; t2 < N; t2++) {
if (t2 == t) {
norms[t2] = Double.POSITIVE_INFINITY;
continue;
}
// Compute norm in the continuous space
norms[t2] = normCalculator.norm(continuousData[t], continuousData[t2]);
}
// Then find the k closest neighbours in the same discrete bin
double eps_x = MatrixUtils.kthMinSubjectTo(norms, k, discreteData, discreteData[t]);
// Count the number of points whose x distance is less
// than or equal to eps_x
int n_x = 0;
for (int t2 = 0; t2 < N; t2++) {
if (norms[t2] <= eps_x) {
n_x++;
}
}
// n_y is number of points in that bin, minus that point
int n_y = counts[discreteData[t]] - 1;
avNx += n_x;
avNy += n_y;
// And take the digamma before adding into the
// average:
double localSum = MathsUtils.digamma(n_x) + MathsUtils.digamma(n_y);
averageDiGammas += localSum;
if (debug) {
// Don't need the 1/k correction here because the conditional entropy term
// is taken over the continuous space only. The correction is (m-1)/k
// for an entropy over m subspaces.
// double localValue = MathsUtils.digamma(k) - 1.0/(double)k - localSum + MathsUtils.digamma(N);
// Instead do:
double localValue = digammaK + digammaN - localSum;
testSum += localValue;
if (dimensions == 1) {
System.out.printf("t=%d: x=%.3f, eps_x=%.3f, n_x=%d, n_y=%d, local=%.3f, running total = %.5f\n",
t, continuousData[t][0], eps_x, n_x, n_y, localValue, testSum);
} else {
System.out.printf("t=%d: eps_x=%.3f, n_x=%d, n_y=%d, local=%.3f, running total = %.5f\n",
t, eps_x, n_x, n_y, localValue, testSum);
}
}
}
averageDiGammas /= (double) N;
if (debug) {
avNx /= (double)N;
avNy /= (double)N;
System.out.println(String.format("Average n_x=%.3f, Average n_y=%.3f", avNx, avNy));
}
// Don't need the 1/k correction here because the conditional entropy term
// is taken over the continuous space only. The correction is (m-1)/k
// for an entropy over m subspaces.
// mi = MathsUtils.digamma(k) - 1.0/(double)k - averageDiGammas + MathsUtils.digamma(N);
// Instead do:
mi = digammaK + digammaN - averageDiGammas;
miComputed = true;
return mi;
}
/**
* Compute the significance of the mutual information of the previously supplied observations.