mirror of https://github.com/jlizier/jidt
Adding univariate calls for cross CMI
This commit is contained in:
parent
fa21f7343a
commit
c08aeb1783
|
|
@ -623,6 +623,38 @@ public interface ConditionalMutualInfoCalculatorMultiVariate
|
|||
public double[] computeLocalUsingPreviousObservations(double states1[][], double states2[][], double[][] condStates)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* <p>As per {@link #computeLocalUsingPreviousObservations(double[][], double[][], double[][])}
|
||||
* but can only be used where dimensions of
|
||||
* states1 and states2 have been set to 1.</p>
|
||||
*
|
||||
* @param states1 series of univariate observations for variable 1
|
||||
* @param states2 series of univariate observations for variable 2
|
||||
* Length must match <code>states1</code>, and their indices must correspond.
|
||||
* @param condStates series of multivariate observations for the conditional
|
||||
* (first index is time or observation index, second is variable number).
|
||||
* Length must match <code>states1</code>, and their indices must correspond.
|
||||
* @return the series of local conditional MI values.
|
||||
* @throws Exception
|
||||
*/
|
||||
public double[] computeLocalUsingPreviousObservations(double states1[], double states2[], double[][] condStates)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* <p>As per {@link #computeLocalUsingPreviousObservations(double[][], double[][], double[][])}
|
||||
* but can only be used all dimensions have been set to 1.</p>
|
||||
*
|
||||
* @param states1 series of univariate observations for variable 1
|
||||
* @param states2 series of univariate observations for variable 2.
|
||||
* Length must match <code>states1</code>, and their indices must correspond.
|
||||
* @param condStates series of univariate observations for the conditional.
|
||||
* Length must match <code>states1</code>, and their indices must correspond.
|
||||
* @return the series of local conditional MI values.
|
||||
* @throws Exception
|
||||
*/
|
||||
public double[] computeLocalUsingPreviousObservations(double states1[], double states2[], double[] condStates)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* @throws Exception if the implementing class computes MI without
|
||||
* explicit observations (e.g. see
|
||||
|
|
|
|||
|
|
@ -935,6 +935,34 @@ public abstract class ConditionalMutualInfoMultiVariateCommon implements
|
|||
return miSurrogateCalculator.computeAverageLocalOfObservations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] computeLocalUsingPreviousObservations(double[] states1, double[] states2, double[][] condStates)
|
||||
throws Exception {
|
||||
if ((dimensionsVar1 != 1) || (dimensionsVar2 != 1)) {
|
||||
throw new Exception("The number of source and dest dimensions (having been initialised to " +
|
||||
dimensionsVar1 + " and " + dimensionsVar2 + ") can only be 1 when " +
|
||||
"the univariate computeLocalUsingPreviousObservations(double[],double[],double[][]) " +
|
||||
"method is called");
|
||||
}
|
||||
return computeLocalUsingPreviousObservations(MatrixUtils.reshape(states1, states1.length, 1),
|
||||
MatrixUtils.reshape(states2, states2.length, 1),
|
||||
condStates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] computeLocalUsingPreviousObservations(double[] states1, double[] states2, double[] condStates)
|
||||
throws Exception {
|
||||
if ((dimensionsVar1 != 1) || (dimensionsVar2 != 1) || (dimensionsCond != 1)) {
|
||||
throw new Exception("The number of source, dest and conditional dimensions (having been initialised to " +
|
||||
dimensionsVar1 + ", " + dimensionsVar2 + " and " + dimensionsCond + ") can only be 1 when " +
|
||||
"the univariate computeLocalUsingPreviousObservations(double[],double[],double[]) " +
|
||||
"method is called");
|
||||
}
|
||||
return computeLocalUsingPreviousObservations(MatrixUtils.reshape(states1, states1.length, 1),
|
||||
MatrixUtils.reshape(states2, states2.length, 1),
|
||||
MatrixUtils.reshape(condStates, condStates.length, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug = debug;
|
||||
|
|
|
|||
Loading…
Reference in New Issue