mirror of https://github.com/jlizier/jidt
Making continuous PredictiveInfoCalculator classes implement the InfoMeasureCalculatorContinuous interface. For the interfaces, this means removing methods where duplicated. And fixed the common implementing class to have the missing getProperty method.
This commit is contained in:
parent
65c7cd99cc
commit
057f17e338
|
|
@ -94,7 +94,8 @@ import infodynamics.utils.EmpiricalNullDistributionComputer;
|
|||
* @author Joseph Lizier (<a href="joseph.lizier at gmail.com">email</a>,
|
||||
* <a href="http://lizier.me/joseph/">www</a>)
|
||||
*/
|
||||
public interface PredictiveInfoCalculator extends EmpiricalNullDistributionComputer {
|
||||
public interface PredictiveInfoCalculator
|
||||
extends InfoMeasureCalculatorContinuous, EmpiricalNullDistributionComputer {
|
||||
|
||||
/**
|
||||
* Property name for embedding length <code>k</code> of
|
||||
|
|
@ -117,13 +118,6 @@ public interface PredictiveInfoCalculator extends EmpiricalNullDistributionCompu
|
|||
*/
|
||||
public static final String TAU_PROP_NAME = "TAU";
|
||||
|
||||
/**
|
||||
* Initialise the calculator for (re-)use, with the existing (or default) values of parameters
|
||||
* Clears any PDFs of previously supplied observations.
|
||||
*
|
||||
*/
|
||||
public void initialise() throws Exception;
|
||||
|
||||
/**
|
||||
* Initialise the calculator for (re-)use, with some parameters
|
||||
* supplied here, and existing (or default) values of other parameters
|
||||
|
|
@ -166,6 +160,7 @@ public interface PredictiveInfoCalculator extends EmpiricalNullDistributionCompu
|
|||
* @param propertyValue value of the property
|
||||
* @throws Exception for invalid property values
|
||||
*/
|
||||
@Override
|
||||
public void setProperty(String propertyName, String propertyValue) throws Exception;
|
||||
|
||||
/**
|
||||
|
|
@ -234,13 +229,6 @@ public interface PredictiveInfoCalculator extends EmpiricalNullDistributionCompu
|
|||
public void setObservations(double[] observations,
|
||||
boolean[] valid) throws Exception;
|
||||
|
||||
/**
|
||||
* Compute the PI from the previously-supplied samples.
|
||||
*
|
||||
* @return the PI estimate
|
||||
*/
|
||||
public double computeAverageLocalOfObservations() throws Exception;
|
||||
|
||||
/**
|
||||
* Compute the local PI values for each of the
|
||||
* previously-supplied samples.
|
||||
|
|
@ -282,36 +270,4 @@ public interface PredictiveInfoCalculator extends EmpiricalNullDistributionCompu
|
|||
*/
|
||||
public double[] computeLocalUsingPreviousObservations(double[] newObservations) throws Exception;
|
||||
|
||||
/**
|
||||
* Set or clear debug mode for extra debug printing to stdout
|
||||
*
|
||||
* @param debug new setting for debug mode (on/off)
|
||||
*/
|
||||
public void setDebug(boolean debug);
|
||||
|
||||
/**
|
||||
* Return the PI last calculated in a call to {@link #computeAverageLocalOfObservations()}
|
||||
* or {@link #computeLocalOfPreviousObservations()} after the previous
|
||||
* {@link #initialise()} call.
|
||||
*
|
||||
* @return the last computed PI value
|
||||
*/
|
||||
public double getLastAverage();
|
||||
|
||||
/**
|
||||
* Get the number of samples to be used for the PDFs here
|
||||
* which have been supplied by calls to
|
||||
* {@link #setObservations(double[])}, {@link #addObservations(double[])}
|
||||
* etc.
|
||||
*
|
||||
* <p>Note that the number of samples is not equal to the length of time-series
|
||||
* supplied (since we need to accumulate the first and last
|
||||
* <code>(k-1)*tau + 1</code>
|
||||
* values of each time-series).
|
||||
* </p>
|
||||
*
|
||||
* @return the number of samples to be used for the PDFs
|
||||
* @throws Exception
|
||||
*/
|
||||
public int getNumObservations() throws Exception;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,6 +217,22 @@ public class PredictiveInfoCalculatorViaMutualInfo implements
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProperty(String propertyName) throws Exception {
|
||||
if (propertyName.equalsIgnoreCase(K_PROP_NAME) ||
|
||||
propertyName.equalsIgnoreCase(K_EMBEDDING_PROP_NAME)) {
|
||||
return Integer.toString(k);
|
||||
} else if (propertyName.equalsIgnoreCase(TAU_PROP_NAME)) {
|
||||
return Integer.toString(tau);
|
||||
} else {
|
||||
// No property was set on this class, assume it is for the underlying
|
||||
// MI calculator, even if it is for
|
||||
// MutualInfoCalculatorMultiVariate.PROP_TIME_DIFF which
|
||||
// is not a valid property for the PI calculator:
|
||||
return miCalc.getProperty(propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see infodynamics.measures.continuous.PredictiveInfoCalculator#setObservations(double[])
|
||||
*/
|
||||
|
|
@ -372,9 +388,6 @@ public class PredictiveInfoCalculatorViaMutualInfo implements
|
|||
return startAndEndTimePairs;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see infodynamics.measures.continuous.PredictiveInfoCalculator#computeAverageLocalOfObservations()
|
||||
*/
|
||||
@Override
|
||||
public double computeAverageLocalOfObservations() throws Exception {
|
||||
return miCalc.computeAverageLocalOfObservations();
|
||||
|
|
@ -434,26 +447,17 @@ public class PredictiveInfoCalculatorViaMutualInfo implements
|
|||
return miCalc.computeSignificance(newOrderings);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see infodynamics.measures.continuous.PredictiveInfoCalculator#setDebug(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug = debug;
|
||||
miCalc.setDebug(debug);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see infodynamics.measures.continuous.PredictiveInfoCalculator#getLastAverage()
|
||||
*/
|
||||
@Override
|
||||
public double getLastAverage() {
|
||||
return miCalc.getLastAverage();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see infodynamics.measures.continuous.PredictiveInfoCalculator#getNumObservations()
|
||||
*/
|
||||
@Override
|
||||
public int getNumObservations() throws Exception {
|
||||
return miCalc.getNumObservations();
|
||||
|
|
|
|||
Loading…
Reference in New Issue