mirror of https://github.com/jlizier/jidt
Added to AutoAnalyser GUI for AIS surrogate-based bias correction (parameter being the number of surrogates) for max AIS corrected auto embedding, for kernel estimator as well as Gaussian (as an alternative to analytic). Also includes the implementing code for AIS Gaussian (was already committed for kernel)
This commit is contained in:
parent
1c2082e74a
commit
9dbe2f8578
|
|
@ -24,6 +24,7 @@ import infodynamics.measures.continuous.InfoMeasureCalculatorContinuous;
|
|||
import infodynamics.measures.continuous.gaussian.ActiveInfoStorageCalculatorGaussian;
|
||||
import infodynamics.measures.continuous.gaussian.MutualInfoCalculatorMultiVariateGaussian;
|
||||
import infodynamics.measures.continuous.kernel.ActiveInfoStorageCalculatorKernel;
|
||||
import infodynamics.measures.continuous.kernel.ActiveInfoStorageCalculatorMultiVariateKernel;
|
||||
import infodynamics.measures.continuous.kernel.MutualInfoCalculatorMultiVariateKernel;
|
||||
import infodynamics.measures.continuous.kraskov.ActiveInfoStorageCalculatorKraskov;
|
||||
import infodynamics.measures.continuous.kraskov.MutualInfoCalculatorMultiVariateKraskov;
|
||||
|
|
@ -158,29 +159,37 @@ public class AutoAnalyserAIS extends AutoAnalyser {
|
|||
};
|
||||
// Gaussian properties:
|
||||
gaussianProperties = new String[] {
|
||||
MutualInfoCalculatorMultiVariateGaussian.PROP_BIAS_CORRECTION
|
||||
MutualInfoCalculatorMultiVariateGaussian.PROP_BIAS_CORRECTION,
|
||||
ActiveInfoStorageCalculatorGaussian.PROP_MAX_CORR_AIS_NUM_SURROGATES
|
||||
};
|
||||
gaussianPropertiesFieldNames = new String[] {
|
||||
"MutualInfoCalculatorMultiVariateGaussian.PROP_BIAS_CORRECTION"
|
||||
"MutualInfoCalculatorMultiVariateGaussian.PROP_BIAS_CORRECTION",
|
||||
"ActiveInfoStorageCalculatorGaussian.PROP_MAX_CORR_AIS_NUM_SURROGATES"
|
||||
};
|
||||
gaussianPropertyDescriptions = new String[] {
|
||||
"Whether the analytically determined bias (as the mean of the<br/>" +
|
||||
"surrogate distribution) will be subtracted from all" +
|
||||
"calculated values. Default is false."
|
||||
"calculated values. Default is false.",
|
||||
"Number of surrogates to use in computing the bias correction<br/>if required for " +
|
||||
ActiveInfoStorageCalculatorKraskov.AUTO_EMBED_METHOD_MAX_CORR_AIS + " auto-embedding method.<br/>" +
|
||||
"(default is 0, meaning to use analytic method -- recommended)"
|
||||
};
|
||||
gaussianPropertyValueChoices = new String[][] {
|
||||
{"true", "false"}
|
||||
{"true", "false"},
|
||||
null
|
||||
};
|
||||
// Kernel:
|
||||
kernelProperties = new String[] {
|
||||
MutualInfoCalculatorMultiVariateKernel.KERNEL_WIDTH_PROP_NAME,
|
||||
MutualInfoCalculatorMultiVariateKernel.DYN_CORR_EXCL_TIME_NAME,
|
||||
MutualInfoCalculatorMultiVariateKernel.NORMALISE_PROP_NAME,
|
||||
MutualInfoCalculatorMultiVariateKernel.NORMALISE_PROP_NAME,
|
||||
ActiveInfoStorageCalculatorMultiVariateKernel.PROP_MAX_CORR_AIS_NUM_SURROGATES
|
||||
};
|
||||
kernelPropertiesFieldNames = new String[] {
|
||||
"MutualInfoCalculatorMultiVariateKernel.KERNEL_WIDTH_PROP_NAME",
|
||||
"MutualInfoCalculatorMultiVariateKernel.DYN_CORR_EXCL_TIME_NAME",
|
||||
"MutualInfoCalculatorMultiVariateKernel.NORMALISE_PROP_NAME"
|
||||
"MutualInfoCalculatorMultiVariateKernel.NORMALISE_PROP_NAME",
|
||||
"ActiveInfoStorageCalculatorMultiVariateKernel.PROP_MAX_CORR_AIS_NUM_SURROGATES"
|
||||
};
|
||||
kernelPropertyDescriptions = new String[] {
|
||||
"Kernel width to be used in the calculation. <br/>If the property " +
|
||||
|
|
@ -190,11 +199,15 @@ public class AutoAnalyserAIS extends AutoAnalyser {
|
|||
"Dynamic correlation exclusion time or <br/>Theiler window (see Kantz and Schreiber); " +
|
||||
"0 (default) means no dynamic exclusion window",
|
||||
"(boolean) whether to normalise <br/>each incoming time-series to mean 0, standard deviation 1, or not (default true, recommended)",
|
||||
"Number of surrogates to use in computing the bias correction<br/>if required for " +
|
||||
ActiveInfoStorageCalculatorKraskov.AUTO_EMBED_METHOD_MAX_CORR_AIS + " auto-embedding method.<br/>" +
|
||||
"(default is 20)"
|
||||
};
|
||||
kernelPropertyValueChoices = new String[][] {
|
||||
null,
|
||||
null,
|
||||
{"true", "false"}
|
||||
{"true", "false"},
|
||||
null
|
||||
};
|
||||
// KSG (Kraskov):
|
||||
kraskovProperties = new String[] {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import infodynamics.measures.continuous.ActiveInfoStorageCalculatorViaMutualInfo
|
|||
import infodynamics.measures.continuous.MutualInfoCalculatorMultiVariate;
|
||||
import infodynamics.utils.AnalyticNullDistributionComputer;
|
||||
import infodynamics.utils.ChiSquareMeasurementDistribution;
|
||||
import infodynamics.utils.EmpiricalMeasurementDistribution;
|
||||
|
||||
/**
|
||||
* An Active Information Storage (AIS) calculator (implementing {@link ActiveInfoStorageCalculator})
|
||||
|
|
@ -71,6 +72,20 @@ public class ActiveInfoStorageCalculatorGaussian
|
|||
|
||||
public static final String MI_CALCULATOR_GAUSSIAN = MutualInfoCalculatorMultiVariateGaussian.class.getName();
|
||||
|
||||
/**
|
||||
* Property name for the number of surrogates to use in computing the bias correction
|
||||
* if required for the {@link ActiveInfoStorageCalculatorViaMutualInfo#AUTO_EMBED_METHOD_MAX_CORR_AIS}
|
||||
* auto embedding method. Defaults to 0 meaning that we use analytic bias correction rather than empirical
|
||||
* surrogates. Note: This is not used for bias correction of the raw values, only for auto-embedding
|
||||
*/
|
||||
public static final String PROP_MAX_CORR_AIS_NUM_SURROGATES = "AUTO_EMBED_MAX_CORR_AIS_SURROGATES";
|
||||
/**
|
||||
* Internal variable for storing the number of surrogates to use for the
|
||||
* auto-embedding {@link ActiveInfoStorageCalculatorViaMutualInfo#AUTO_EMBED_METHOD_MAX_CORR_AIS}
|
||||
* method. 0 mean we use analytic approaches rather than surrogates.
|
||||
*/
|
||||
protected int auto_embed_num_surrogates = 0;
|
||||
|
||||
/**
|
||||
* Creates a new instance of the Gaussian-estimate style active info storage calculator
|
||||
* @throws ClassNotFoundException
|
||||
|
|
@ -82,16 +97,76 @@ public class ActiveInfoStorageCalculatorGaussian
|
|||
super(MI_CALCULATOR_GAUSSIAN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets properties for the AIS Gaussian calculator.
|
||||
* New property values are not guaranteed to take effect until the next call
|
||||
* to an initialise method.
|
||||
*
|
||||
* <p>Valid property names, and what their
|
||||
* values should represent, include:</p>
|
||||
* <ul>
|
||||
* <li>{@link #PROP_MAX_CORR_AIS_NUM_SURROGATES} -- number of surrogates to use
|
||||
* to compute the bias correction
|
||||
* in the auto-embedding if the property {@link #PROP_AUTO_EMBED_METHOD}
|
||||
* has been set to {@link #AUTO_EMBED_METHOD_MAX_CORR_AIS}. Defaults to 0
|
||||
* meaning that we use analytic bias correction.
|
||||
* Note: this is not used for other bias-correction, only inside auto-embedding</li>
|
||||
* <li>Any properties accepted by {@link super#setProperty(String, String)}</li>
|
||||
* <li>Or properties accepted by the underlying
|
||||
* {@link MutualInfoCalculatorMultiVariateGaussian#setProperty(String, String)} implementation.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param propertyName name of the property
|
||||
* @param propertyValue value of the property.
|
||||
* @throws Exception if there is a problem with the supplied value).
|
||||
*/
|
||||
@Override
|
||||
public void setProperty(String propertyName, String propertyValue)
|
||||
throws Exception {
|
||||
boolean propertySet = true;
|
||||
if (propertyName.equalsIgnoreCase(PROP_MAX_CORR_AIS_NUM_SURROGATES)) {
|
||||
auto_embed_num_surrogates = Integer.parseInt(propertyValue);
|
||||
} else {
|
||||
propertySet = false;
|
||||
// Assume it was a property for the parent class or underlying MI calculator
|
||||
super.setProperty(propertyName, propertyValue);
|
||||
}
|
||||
if (debug && propertySet) {
|
||||
System.out.println(this.getClass().getSimpleName() + ": Set property " + propertyName +
|
||||
" to " + propertyValue);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProperty(String propertyName)
|
||||
throws Exception {
|
||||
|
||||
if (propertyName.equalsIgnoreCase(PROP_MAX_CORR_AIS_NUM_SURROGATES)) {
|
||||
return Integer.toString(auto_embed_num_surrogates);
|
||||
} else {
|
||||
// Assume it was a property for the parent class or underlying MI calculator
|
||||
return super.getProperty(propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double computeAdditionalBiasToRemove() throws Exception {
|
||||
boolean biasCorrected = Boolean.getBoolean(getProperty(MutualInfoCalculatorMultiVariateGaussian.PROP_BIAS_CORRECTION));
|
||||
if (!biasCorrected) {
|
||||
ChiSquareMeasurementDistribution analyticMeasDist =
|
||||
((MutualInfoCalculatorMultiVariateGaussian)miCalc).computeSignificance();
|
||||
return analyticMeasDist.getMeanOfDistribution();
|
||||
if (auto_embed_num_surrogates == 0) {
|
||||
// Analytic bias correction:
|
||||
if (!biasCorrected) {
|
||||
ChiSquareMeasurementDistribution analyticMeasDist =
|
||||
((MutualInfoCalculatorMultiVariateGaussian)miCalc).computeSignificance();
|
||||
return analyticMeasDist.getMeanOfDistribution();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
// Empirical bias correction with auto_embed_num_surrogates surrogates:
|
||||
EmpiricalMeasurementDistribution measDist =
|
||||
miCalc.computeSignificance(auto_embed_num_surrogates);
|
||||
return measDist.getMeanOfDistribution();
|
||||
}
|
||||
// else it was already bias corrected
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -117,7 +192,7 @@ public class ActiveInfoStorageCalculatorGaussian
|
|||
* toolkit for studying the dynamics of complex systems', 2014."
|
||||
* @throws Exception
|
||||
*/
|
||||
public ChiSquareMeasurementDistribution computeSignificance() {
|
||||
public ChiSquareMeasurementDistribution computeSignificance() throws Exception {
|
||||
return ((MutualInfoCalculatorMultiVariateGaussian) miCalc).computeSignificance();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue