diff --git a/java/source/infodynamics/measures/continuous/ConditionalMutualInfoCalculatorMultiVariate.java b/java/source/infodynamics/measures/continuous/ConditionalMutualInfoCalculatorMultiVariate.java index a86ce64..6c1e03c 100755 --- a/java/source/infodynamics/measures/continuous/ConditionalMutualInfoCalculatorMultiVariate.java +++ b/java/source/infodynamics/measures/continuous/ConditionalMutualInfoCalculatorMultiVariate.java @@ -114,6 +114,29 @@ public interface ConditionalMutualInfoCalculatorMultiVariate public void setObservations(double[][] var1, double[][] var2, double[][] cond) throws Exception; + /** + * Sets a single series from which to compute the PDF. + * Cannot be called in conjunction with + * {@link #startAddObservations()} / {@link #addObservations(double[][], double[][], double[][])} or + * {@link #addObservations(double[][], double[][], double[][], int, int)} / + * {@link #finaliseAddObservations()}.

+ * + *

The supplied series may be (multivariate) time-series or + * simply a set of separate observations without a time interpretation. + * + *

This method can only be used where dimensions of all + * variables have been set to 1.

+ * + * @param var1 univariate observations for variable 1 + * @param var2 univariate observations for variable 2 + * Length must match var1, and their indices must correspond. + * @param cond univariate observations for the conditional + * Length must match var1, and their indices must correspond. + * @throws Exception + */ + public void setObservations(double[] var1, double[] var2, + double[] cond) throws Exception; + /** * Sets a single series from which to compute the PDF, * where all the various observations are valid. @@ -210,6 +233,31 @@ public interface ConditionalMutualInfoCalculatorMultiVariate public void addObservations(double[][] var1, double[][] var2, double[][] cond) throws Exception; + /** + *

Adds a new set of observations to update the PDFs with - is + * intended to be called multiple times. + * Must be called after {@link #startAddObservations()}; call + * {@link #finaliseAddObservations()} once all observations have + * been supplied.

+ * + *

Note that the arrays must not be over-written by the user + * until after finaliseAddObservations() has been called + * (they are not copied by this method necessarily, but the method + * may simply hold a pointer to them).

+ * + *

This method can only be used where dimensions of all + * variables have been set to 1.

+ * + * @param var1 univariate observations for variable 1 + * @param var2 univariate observations for variable 2 + * Length must match var1, and their indices must correspond. + * @param cond univariate observations for the conditional + * Length must match var1, and their indices must correspond. + * @throws Exception + */ + public void addObservations(double[] var1, double[] var2, + double[] cond) throws Exception; + /** *

Adds a new sub-series of observations to update the PDFs with - is * intended to be called multiple times. diff --git a/java/source/infodynamics/measures/continuous/ConditionalMutualInfoMultiVariateCommon.java b/java/source/infodynamics/measures/continuous/ConditionalMutualInfoMultiVariateCommon.java index dd5460e..557ca24 100755 --- a/java/source/infodynamics/measures/continuous/ConditionalMutualInfoMultiVariateCommon.java +++ b/java/source/infodynamics/measures/continuous/ConditionalMutualInfoMultiVariateCommon.java @@ -237,6 +237,15 @@ public abstract class ConditionalMutualInfoMultiVariateCommon implements addedMoreThanOneObservationSet = false; } + @Override + public void setObservations(double[] var1, double[] var2, + double[] cond) throws Exception { + startAddObservations(); + addObservations(var1, var2, cond); + finaliseAddObservations(); + addedMoreThanOneObservationSet = false; + } + @Override public void startAddObservations() { vectorOfVar1Observations = new Vector(); @@ -276,6 +285,23 @@ public abstract class ConditionalMutualInfoMultiVariateCommon implements } } + @Override + public void addObservations(double[] var1, double[] var2, + double[] cond) throws Exception { + if ((dimensionsVar1 != 1) || (dimensionsVar2 != 1) || + (dimensionsCond != 1)) { + throw new Exception("The number of dimensions for each variable (having been initialised to " + + dimensionsVar1 + ", " + dimensionsVar2 + " & " + + dimensionsCond + ") can only be 1 when " + + "the univariate addObservations(double[],double[],double[]) and " + + "setObservations(double[],double[],double[]) methods are called"); + } + addObservations(MatrixUtils.reshape(var1, var1.length, 1), + MatrixUtils.reshape(var2, var2.length, 1), + MatrixUtils.reshape(cond, cond.length, 1)); + + } + @Override public void addObservations(double[][] var1, double[][] var2, double[][] cond,