mirror of https://github.com/jlizier/jidt
Renaming ApparentTransferEntropyCalculator to TransferEntropyCalculator for simplicity -- step 1 of 2
This commit is contained in:
parent
ab916e2253
commit
7e27c0d4ed
|
|
@ -1,8 +1,7 @@
|
||||||
package infodynamics.measures.continuous.symbolic;
|
package infodynamics.measures.continuous.symbolic;
|
||||||
|
|
||||||
import infodynamics.measures.continuous.TransferEntropyCalculator;
|
|
||||||
import infodynamics.measures.continuous.TransferEntropyCommon;
|
import infodynamics.measures.continuous.TransferEntropyCommon;
|
||||||
import infodynamics.measures.discrete.ApparentTransferEntropyCalculator;
|
import infodynamics.measures.discrete.TransferEntropyCalculator;
|
||||||
import infodynamics.utils.FirstIndexComparatorDouble;
|
import infodynamics.utils.FirstIndexComparatorDouble;
|
||||||
import infodynamics.utils.MathsUtils;
|
import infodynamics.utils.MathsUtils;
|
||||||
import infodynamics.utils.MatrixUtils;
|
import infodynamics.utils.MatrixUtils;
|
||||||
|
|
@ -22,10 +21,10 @@ import java.util.Vector;
|
||||||
*/
|
*/
|
||||||
public class TransferEntropyCalculatorSymbolic
|
public class TransferEntropyCalculatorSymbolic
|
||||||
extends TransferEntropyCommon
|
extends TransferEntropyCommon
|
||||||
implements TransferEntropyCalculator {
|
implements infodynamics.measures.continuous.TransferEntropyCalculator {
|
||||||
|
|
||||||
// The calculator used to do the grunt work
|
// The calculator used to do the grunt work
|
||||||
protected ApparentTransferEntropyCalculator teCalc;
|
protected TransferEntropyCalculator teCalc;
|
||||||
|
|
||||||
protected int maxEmbeddingLength; // = Max(l,k)
|
protected int maxEmbeddingLength; // = Max(l,k)
|
||||||
// l will default to the value of k unless l gets explicitly set
|
// l will default to the value of k unless l gets explicitly set
|
||||||
|
|
@ -126,7 +125,7 @@ public class TransferEntropyCalculatorSymbolic
|
||||||
// The discrete calculator only uses a history of 1 here - k is built into
|
// The discrete calculator only uses a history of 1 here - k is built into
|
||||||
// the permutations
|
// the permutations
|
||||||
int base = Math.max(destPermutationIds.length, sourcePermutationIds.length);
|
int base = Math.max(destPermutationIds.length, sourcePermutationIds.length);
|
||||||
teCalc = ApparentTransferEntropyCalculator.newInstance(base, 1);
|
teCalc = TransferEntropyCalculator.newInstance(base, 1);
|
||||||
teCalc.initialise();
|
teCalc.initialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ import infodynamics.utils.RandomGenerator;
|
||||||
* <a href="http://lizier.me/joseph/">www</a>
|
* <a href="http://lizier.me/joseph/">www</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ApparentTransferEntropyCalculator extends ContextOfPastMeasureCalculator
|
public class TransferEntropyCalculator extends ContextOfPastMeasureCalculator
|
||||||
implements ChannelCalculator, AnalyticNullDistributionComputer {
|
implements ChannelCalculator, AnalyticNullDistributionComputer {
|
||||||
|
|
||||||
protected int[][][] sourceNextPastCount = null; // count for (source[n],dest[n+1],dest[n]^k) tuples
|
protected int[][][] sourceNextPastCount = null; // count for (source[n],dest[n+1],dest[n]^k) tuples
|
||||||
|
|
@ -107,9 +107,9 @@ public class ApparentTransferEntropyCalculator extends ContextOfPastMeasureCalcu
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ApparentTransferEntropyCalculator newInstance(int base, int destHistoryEmbedLength) {
|
public static TransferEntropyCalculator newInstance(int base, int destHistoryEmbedLength) {
|
||||||
|
|
||||||
return new ApparentTransferEntropyCalculator(base, destHistoryEmbedLength);
|
return new TransferEntropyCalculator(base, destHistoryEmbedLength);
|
||||||
|
|
||||||
// Old code for an attempted optimisation:
|
// Old code for an attempted optimisation:
|
||||||
/*
|
/*
|
||||||
|
|
@ -129,7 +129,7 @@ public class ApparentTransferEntropyCalculator extends ContextOfPastMeasureCalcu
|
||||||
* @param destHistoryEmbedLength embedded history length of the destination to condition on -
|
* @param destHistoryEmbedLength embedded history length of the destination to condition on -
|
||||||
* this is k in Schreiber's notation.
|
* this is k in Schreiber's notation.
|
||||||
*/
|
*/
|
||||||
public ApparentTransferEntropyCalculator(int base, int destHistoryEmbedLength) {
|
public TransferEntropyCalculator(int base, int destHistoryEmbedLength) {
|
||||||
|
|
||||||
super(base, destHistoryEmbedLength);
|
super(base, destHistoryEmbedLength);
|
||||||
base_power_l = MathsUtils.power(base, sourceHistoryEmbedLength);
|
base_power_l = MathsUtils.power(base, sourceHistoryEmbedLength);
|
||||||
|
|
@ -160,7 +160,7 @@ public class ApparentTransferEntropyCalculator extends ContextOfPastMeasureCalcu
|
||||||
* @param sourceHistoryEmbeddingLength embedded history length of the source to include -
|
* @param sourceHistoryEmbeddingLength embedded history length of the source to include -
|
||||||
* this is l in Schreiber's notation.
|
* this is l in Schreiber's notation.
|
||||||
*/
|
*/
|
||||||
public ApparentTransferEntropyCalculator(int base, int destHistoryEmbedLength, int sourceHistoryEmbeddingLength) {
|
public TransferEntropyCalculator(int base, int destHistoryEmbedLength, int sourceHistoryEmbeddingLength) {
|
||||||
|
|
||||||
super(base, destHistoryEmbedLength);
|
super(base, destHistoryEmbedLength);
|
||||||
this.sourceHistoryEmbedLength = sourceHistoryEmbeddingLength;
|
this.sourceHistoryEmbedLength = sourceHistoryEmbeddingLength;
|
||||||
|
|
@ -968,7 +968,7 @@ public class ApparentTransferEntropyCalculator extends ContextOfPastMeasureCalcu
|
||||||
// of resources here, but there's not much other choice. A better solution
|
// of resources here, but there's not much other choice. A better solution
|
||||||
// will come when we switch to an underlying conditional MI calculator, with separate
|
// will come when we switch to an underlying conditional MI calculator, with separate
|
||||||
// bases for each variable, and just use its computeSignificance() method.
|
// bases for each variable, and just use its computeSignificance() method.
|
||||||
ApparentTransferEntropyCalculator ate2 = new ApparentTransferEntropyCalculator(base_power_l, k, 1);
|
TransferEntropyCalculator ate2 = new TransferEntropyCalculator(base_power_l, k, 1);
|
||||||
ate2.initialise();
|
ate2.initialise();
|
||||||
ate2.observations = observations;
|
ate2.observations = observations;
|
||||||
ate2.pastCount = pastCount;
|
ate2.pastCount = pastCount;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import infodynamics.utils.MatrixUtils;
|
||||||
public class SeparableInfoCalculatorByAddition extends SeparableInfoCalculator {
|
public class SeparableInfoCalculatorByAddition extends SeparableInfoCalculator {
|
||||||
|
|
||||||
ActiveInformationCalculator aiCalc;
|
ActiveInformationCalculator aiCalc;
|
||||||
ApparentTransferEntropyCalculator[] ateCalcs;
|
TransferEntropyCalculator[] ateCalcs;
|
||||||
|
|
||||||
private boolean localStatsValid = true;
|
private boolean localStatsValid = true;
|
||||||
|
|
||||||
|
|
@ -26,9 +26,9 @@ public class SeparableInfoCalculatorByAddition extends SeparableInfoCalculator {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void createAppTeCalculators() {
|
private void createAppTeCalculators() {
|
||||||
ateCalcs = new ApparentTransferEntropyCalculator[numSources];
|
ateCalcs = new TransferEntropyCalculator[numSources];
|
||||||
for (int i = 0; i < numSources; i++) {
|
for (int i = 0; i < numSources; i++) {
|
||||||
ateCalcs[i] = ApparentTransferEntropyCalculator.newInstance(base, k);
|
ateCalcs[i] = TransferEntropyCalculator.newInstance(base, k);
|
||||||
ateCalcs[i].setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
ateCalcs[i].setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -237,8 +237,8 @@ public class SeparableInfoCalculatorByAddition extends SeparableInfoCalculator {
|
||||||
localComponents[0] = local;
|
localComponents[0] = local;
|
||||||
}
|
}
|
||||||
int[] cleanedOffsets = cleanOffsetOfDestFromSources(offsetOfDestFromSources);
|
int[] cleanedOffsets = cleanOffsetOfDestFromSources(offsetOfDestFromSources);
|
||||||
ApparentTransferEntropyCalculator ateCalc =
|
TransferEntropyCalculator ateCalc =
|
||||||
ApparentTransferEntropyCalculator.newInstance(base, k);
|
TransferEntropyCalculator.newInstance(base, k);
|
||||||
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
||||||
double[][] temp;
|
double[][] temp;
|
||||||
for (int i = 0; i < numSources; i++) {
|
for (int i = 0; i < numSources; i++) {
|
||||||
|
|
@ -273,8 +273,8 @@ public class SeparableInfoCalculatorByAddition extends SeparableInfoCalculator {
|
||||||
localComponents[0] = local;
|
localComponents[0] = local;
|
||||||
}
|
}
|
||||||
int[][] cleanedOffsets = cleanOffsetOfDestFromSources(offsetOfDestFromSources);
|
int[][] cleanedOffsets = cleanOffsetOfDestFromSources(offsetOfDestFromSources);
|
||||||
ApparentTransferEntropyCalculator ateCalc =
|
TransferEntropyCalculator ateCalc =
|
||||||
ApparentTransferEntropyCalculator.newInstance(base, k);
|
TransferEntropyCalculator.newInstance(base, k);
|
||||||
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
||||||
double[][][] temp;
|
double[][][] temp;
|
||||||
for (int i = 0; i < numSources; i++) {
|
for (int i = 0; i < numSources; i++) {
|
||||||
|
|
@ -307,8 +307,8 @@ public class SeparableInfoCalculatorByAddition extends SeparableInfoCalculator {
|
||||||
// ApparentTransferEntropy object
|
// ApparentTransferEntropy object
|
||||||
average = aiCalc.computeAverageLocal(states);
|
average = aiCalc.computeAverageLocal(states);
|
||||||
int[] cleanedOffsets = cleanOffsetOfDestFromSources(sourceOffsets);
|
int[] cleanedOffsets = cleanOffsetOfDestFromSources(sourceOffsets);
|
||||||
ApparentTransferEntropyCalculator ateCalc =
|
TransferEntropyCalculator ateCalc =
|
||||||
ApparentTransferEntropyCalculator.newInstance(base, k);
|
TransferEntropyCalculator.newInstance(base, k);
|
||||||
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
||||||
for (int i = 0; i < numSources; i++) {
|
for (int i = 0; i < numSources; i++) {
|
||||||
average += ateCalc.computeAverageLocal(states, cleanedOffsets[i]);
|
average += ateCalc.computeAverageLocal(states, cleanedOffsets[i]);
|
||||||
|
|
@ -324,8 +324,8 @@ public class SeparableInfoCalculatorByAddition extends SeparableInfoCalculator {
|
||||||
// ApparentTransferEntropy object
|
// ApparentTransferEntropy object
|
||||||
average = aiCalc.computeAverageLocal(states);
|
average = aiCalc.computeAverageLocal(states);
|
||||||
int[][] cleanedOffsets = cleanOffsetOfDestFromSources(sourceOffsets);
|
int[][] cleanedOffsets = cleanOffsetOfDestFromSources(sourceOffsets);
|
||||||
ApparentTransferEntropyCalculator ateCalc =
|
TransferEntropyCalculator ateCalc =
|
||||||
ApparentTransferEntropyCalculator.newInstance(base, k);
|
TransferEntropyCalculator.newInstance(base, k);
|
||||||
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
||||||
for (int i = 0; i < numSources; i++) {
|
for (int i = 0; i < numSources; i++) {
|
||||||
average += ateCalc.computeAverageLocal(states,
|
average += ateCalc.computeAverageLocal(states,
|
||||||
|
|
@ -346,8 +346,8 @@ public class SeparableInfoCalculatorByAddition extends SeparableInfoCalculator {
|
||||||
localComponents[0] = local;
|
localComponents[0] = local;
|
||||||
}
|
}
|
||||||
int[] cleanedOffsets = cleanAbsoluteSources(sourcesAbsolute, destCol);
|
int[] cleanedOffsets = cleanAbsoluteSources(sourcesAbsolute, destCol);
|
||||||
ApparentTransferEntropyCalculator ateCalc =
|
TransferEntropyCalculator ateCalc =
|
||||||
ApparentTransferEntropyCalculator.newInstance(base, k);
|
TransferEntropyCalculator.newInstance(base, k);
|
||||||
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
||||||
double[] temp;
|
double[] temp;
|
||||||
for (int i = 0; i < numSources; i++) {
|
for (int i = 0; i < numSources; i++) {
|
||||||
|
|
@ -382,8 +382,8 @@ public class SeparableInfoCalculatorByAddition extends SeparableInfoCalculator {
|
||||||
localComponents[0] = local;
|
localComponents[0] = local;
|
||||||
}
|
}
|
||||||
int[][] cleanedSourcesAbsolute = cleanAbsoluteSources(sourcesAbsolute, destAgentRow, destAgentColumn);
|
int[][] cleanedSourcesAbsolute = cleanAbsoluteSources(sourcesAbsolute, destAgentRow, destAgentColumn);
|
||||||
ApparentTransferEntropyCalculator ateCalc =
|
TransferEntropyCalculator ateCalc =
|
||||||
ApparentTransferEntropyCalculator.newInstance(base, k);
|
TransferEntropyCalculator.newInstance(base, k);
|
||||||
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
||||||
double[] temp;
|
double[] temp;
|
||||||
for (int i = 0; i < numSources; i++) {
|
for (int i = 0; i < numSources; i++) {
|
||||||
|
|
@ -415,8 +415,8 @@ public class SeparableInfoCalculatorByAddition extends SeparableInfoCalculator {
|
||||||
// ApparentTransferEntropy object
|
// ApparentTransferEntropy object
|
||||||
average = aiCalc.computeAverageLocal(states, destCol);
|
average = aiCalc.computeAverageLocal(states, destCol);
|
||||||
int[] cleanedSourcesAbsolute = cleanAbsoluteSources(sourcesAbsolute, destCol);
|
int[] cleanedSourcesAbsolute = cleanAbsoluteSources(sourcesAbsolute, destCol);
|
||||||
ApparentTransferEntropyCalculator ateCalc =
|
TransferEntropyCalculator ateCalc =
|
||||||
ApparentTransferEntropyCalculator.newInstance(base, k);
|
TransferEntropyCalculator.newInstance(base, k);
|
||||||
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
||||||
for (int i = 0; i < numSources; i++) {
|
for (int i = 0; i < numSources; i++) {
|
||||||
average += ateCalc.computeAverageLocal(states, destCol, cleanedSourcesAbsolute[i]);
|
average += ateCalc.computeAverageLocal(states, destCol, cleanedSourcesAbsolute[i]);
|
||||||
|
|
@ -433,8 +433,8 @@ public class SeparableInfoCalculatorByAddition extends SeparableInfoCalculator {
|
||||||
// ApparentTransferEntropy object
|
// ApparentTransferEntropy object
|
||||||
average = aiCalc.computeAverageLocal(states);
|
average = aiCalc.computeAverageLocal(states);
|
||||||
int[][] cleanedSourcesAbsolute = cleanAbsoluteSources(sourcesAbsolute, destAgentRow, destAgentColumn);
|
int[][] cleanedSourcesAbsolute = cleanAbsoluteSources(sourcesAbsolute, destAgentRow, destAgentColumn);
|
||||||
ApparentTransferEntropyCalculator ateCalc =
|
TransferEntropyCalculator ateCalc =
|
||||||
ApparentTransferEntropyCalculator.newInstance(base, k);
|
TransferEntropyCalculator.newInstance(base, k);
|
||||||
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
ateCalc.setPeriodicBoundaryConditions(periodicBoundaryConditions);
|
||||||
for (int i = 0; i < numSources; i++) {
|
for (int i = 0; i < numSources; i++) {
|
||||||
average += ateCalc.computeAverageLocal(states,
|
average += ateCalc.computeAverageLocal(states,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue