Adding various comments

Patched bug in TECalculatorMultiVariateSingleObservationsKernel whereby only k*destDimensions dimensions of destPast were being considered (this is a problem where one wants to surreptitiously condition on extra variables).
This commit is contained in:
joseph.lizier 2012-12-13 14:42:40 +00:00
parent b64b0c091d
commit e789acd4dc
5 changed files with 41 additions and 7 deletions

View File

@ -96,7 +96,9 @@ public class KernelEstimatorTransferEntropyMultiVariate extends KernelEstimatorM
// epsilonInUse has been computed for the destination.
// TODO We could compute and set it directly here so
// we don't have a mismatch between any of the vector
// variables.
// variables. Don't do this - it allows destPastVectors to hold
// slightly different variables, e.g. in the case of
// TEMultiVariateSingleObservationsKernel
if (normalise) {
for (int d = 0; d < sourceDimensions; d++) {

View File

@ -602,6 +602,8 @@ public class TransferEntropyCalculatorMultiVariateKernel
*
* @param newOrderings first index is permutation number, i.e. newOrderings[i]
* is an array of 1 permutation of 0..n-1, where there were n observations.
* Note that n observations is generally less than the time series length
* if the TE was estimated from a single time series.
* @return
* @throws Exception
*/
@ -615,6 +617,15 @@ public class TransferEntropyCalculatorMultiVariateKernel
// Space for the source observations:
double[][] oldSourceValues = sourceVectors;
// Check that the largest value in the newOrderings is within range:
int maxNewIndex = MatrixUtils.max(newOrderings);
if (maxNewIndex >= sourceVectors.length) {
throw new Exception("Cannot prescribe a new ordering index of " + maxNewIndex +
" since this is outside the range 0..n-1, where n=" +
sourceVectors.length + " is the number of observations that " +
"have been supplied to the calculator.");
}
int countWhereTeIsMoreSignificantThanOriginal = 0;
EmpiricalMeasurementDistribution measDistribution = new EmpiricalMeasurementDistribution(numPermutationsToCheck);
for (int p = 0; p < numPermutationsToCheck; p++) {

View File

@ -85,7 +85,15 @@ public class TransferEntropyCalculatorMultiVariateSingleObservationsKernel
// dimensions if we're not careful)
addedMoreThanOneObservationSet = false;
k = 1;
initialise();
// Mimic super.initialise() (it would use k * destDimenions in the kernel estimator
// for destPast instead of destPastDimensions if we're not careful)
teKernelEstimator.initialise(destPastDimensions,
sourceDimensions, epsilon, epsilon);
nextStateKernelEstimator.initialise(destDimensions, epsilon);
destPastVectors = null;
destNextVectors = null;
sourceVectors = null;
localProbNextCondPast = null;
}
/**

View File

@ -58,6 +58,19 @@ public abstract class MutualInfoCalculatorMultiVariateKraskov implements
// No need to keep the dimenions here
}
/**
* Sets properties for the calculator.
* Valid properties include:
* <ul>
* <li>{@link #PROP_K} - number of neighbouring points in joint kernel space</li>
* <li>{@link #PROP_NORM_TYPE}</li>
* <li>{@link #PROP_NORMALISE}</li>
* <li>{@link MutualInfoCalculatorMultiVariate#PROP_TIME_DIFF}</li>
* </ul>
*
* @param propertyName
* @param propertyValue
*/
public void setProperty(String propertyName, String propertyValue) {
if (propertyName.equalsIgnoreCase(PROP_K)) {
k = Integer.parseInt(propertyValue);

View File

@ -149,12 +149,12 @@ public class TransferEntropyCalculatorKraskovByMulti
* Sets properties for the calculator.
* Valid properties include:
* <ul>
* <li>K_PROP_NAME</li>
* <li>PROP_KRASKOV_ALG_NUM</li>
* <li>Any valid properties for MutualInfoCalculatorMultiVariateKraskov.setProperty except
* for MutualInfoCalculatorMultiVariate.PROP_TIME_DIFF</li>
* <li>{@link TransferEntropyCalculator#K_PROP_NAME} - history length</li>
* <li>{@link #PROP_KRASKOV_ALG_NUM}</li>
* <li>Any valid properties for {@link MutualInfoCalculatorMultiVariateKraskov#setProperty(String, String)} except
* for {@link MutualInfoCalculatorMultiVariate#PROP_TIME_DIFF}</li>
* </ul>
* One should set MutualInfoCalculatorMultiVariateKraskov.PROP_K here, the number
* One should set {@link MutualInfoCalculatorMultiVariateKraskov#PROP_K} here, the number
* of neighbouring points one should count up to in determining the joint kernel size.
*
* @param propertyName