mirror of https://github.com/jlizier/jidt
Implementing Analytic null distributions for discrete conditional TE estimator
This commit is contained in:
parent
a65db51b78
commit
7d7291fb9d
|
|
@ -21,6 +21,9 @@ package infodynamics.measures.discrete;
|
||||||
import infodynamics.utils.EmpiricalNullDistributionComputer;
|
import infodynamics.utils.EmpiricalNullDistributionComputer;
|
||||||
import infodynamics.utils.MathsUtils;
|
import infodynamics.utils.MathsUtils;
|
||||||
import infodynamics.utils.MatrixUtils;
|
import infodynamics.utils.MatrixUtils;
|
||||||
|
import infodynamics.utils.AnalyticMeasurementDistribution;
|
||||||
|
import infodynamics.utils.AnalyticNullDistributionComputer;
|
||||||
|
import infodynamics.utils.ChiSquareMeasurementDistribution;
|
||||||
import infodynamics.utils.EmpiricalMeasurementDistribution;
|
import infodynamics.utils.EmpiricalMeasurementDistribution;
|
||||||
import infodynamics.utils.RandomGenerator;
|
import infodynamics.utils.RandomGenerator;
|
||||||
|
|
||||||
|
|
@ -80,8 +83,6 @@ import infodynamics.utils.RandomGenerator;
|
||||||
* TODO Add methods for passing in single time series.
|
* TODO Add methods for passing in single time series.
|
||||||
* This is done for addObservations, but not other routines.
|
* This is done for addObservations, but not other routines.
|
||||||
*
|
*
|
||||||
* TODO Implement AnalyticNullDistributionComputer
|
|
||||||
*
|
|
||||||
* <p><b>References:</b><br/>
|
* <p><b>References:</b><br/>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>T. Schreiber, <a href="http://dx.doi.org/10.1103/PhysRevLett.85.461">
|
* <li>T. Schreiber, <a href="http://dx.doi.org/10.1103/PhysRevLett.85.461">
|
||||||
|
|
@ -106,7 +107,7 @@ import infodynamics.utils.RandomGenerator;
|
||||||
*/
|
*/
|
||||||
public class ConditionalTransferEntropyCalculatorDiscrete
|
public class ConditionalTransferEntropyCalculatorDiscrete
|
||||||
extends ContextOfPastMeasureCalculatorDiscrete
|
extends ContextOfPastMeasureCalculatorDiscrete
|
||||||
implements EmpiricalNullDistributionComputer {
|
implements EmpiricalNullDistributionComputer, AnalyticNullDistributionComputer {
|
||||||
|
|
||||||
protected int base_others = 0; // base of the conditional variables
|
protected int base_others = 0; // base of the conditional variables
|
||||||
protected int base_power_num_others = 0;
|
protected int base_power_num_others = 0;
|
||||||
|
|
@ -123,6 +124,11 @@ public class ConditionalTransferEntropyCalculatorDiscrete
|
||||||
*/
|
*/
|
||||||
protected int startObservationTime = 1;
|
protected int startObservationTime = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tracks whether the measure has been computed since the last initialisation
|
||||||
|
*/
|
||||||
|
protected boolean estimateComputed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User was formerly forced to create new instances through this factory method.
|
* User was formerly forced to create new instances through this factory method.
|
||||||
* Retained for backwards compatibility.
|
* Retained for backwards compatibility.
|
||||||
|
|
@ -264,6 +270,7 @@ public class ConditionalTransferEntropyCalculatorDiscrete
|
||||||
MatrixUtils.fill(destPastOthersCount, 0);
|
MatrixUtils.fill(destPastOthersCount, 0);
|
||||||
MatrixUtils.fill(pastOthersCount, 0);
|
MatrixUtils.fill(pastOthersCount, 0);
|
||||||
}
|
}
|
||||||
|
estimateComputed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -622,6 +629,7 @@ public class ConditionalTransferEntropyCalculatorDiscrete
|
||||||
|
|
||||||
average = te;
|
average = te;
|
||||||
std = Math.sqrt(meanSqLocals - average * average);
|
std = Math.sqrt(meanSqLocals - average * average);
|
||||||
|
estimateComputed = true;
|
||||||
return te;
|
return te;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -717,6 +725,17 @@ public class ConditionalTransferEntropyCalculatorDiscrete
|
||||||
return measDistribution;
|
return measDistribution;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnalyticMeasurementDistribution computeSignificance()
|
||||||
|
throws Exception {
|
||||||
|
if (!estimateComputed) {
|
||||||
|
computeAverageLocalOfObservations();
|
||||||
|
}
|
||||||
|
return new ChiSquareMeasurementDistribution(average,
|
||||||
|
observations,
|
||||||
|
(base - 1)*(base - 1)*(base_power_k*base_power_num_others));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes local conditional transfer entropy for the given
|
* Computes local conditional transfer entropy for the given
|
||||||
* states, using pdfs built up from observations previously
|
* states, using pdfs built up from observations previously
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue