diff --git a/demos/octave/DetectingInteractionLags/transferWithSourceMemory.m b/demos/octave/DetectingInteractionLags/transferWithSourceMemory.m index cd250ea..233e659 100755 --- a/demos/octave/DetectingInteractionLags/transferWithSourceMemory.m +++ b/demos/octave/DetectingInteractionLags/transferWithSourceMemory.m @@ -77,10 +77,10 @@ function transferWithSourceMemory(savePlot) % Compute TEs teCalc = javaObject('infodynamics.measures.discrete.TransferEntropyCalculator', 4, 1); teCalc.initialise(); - teCalc.addObservations(y, x); + teCalc.addObservations(x, y); teXnToYnplus1(deltaIndex) = teCalc.computeAverageLocalOfObservations(); teCalc.initialise(); - teCalc.addObservations(y(2:length(y)), x(1:length(x)-1)); + teCalc.addObservations(x(1:length(x)-1), y(2:length(y))); teXnminus1ToYnplus1(deltaIndex) = teCalc.computeAverageLocalOfObservations(); % Compute MITs diff --git a/demos/octave/example1TeBinaryData.m b/demos/octave/example1TeBinaryData.m index 7eb3c8c..1f87a57 100755 --- a/demos/octave/example1TeBinaryData.m +++ b/demos/octave/example1TeBinaryData.m @@ -15,11 +15,11 @@ sourceArray2=(rand(100,1)>0.5)*1; teCalc=javaObject('infodynamics.measures.discrete.TransferEntropyCalculator', 2, 1); teCalc.initialise(); % Since we have simple arrays of ints, we can directly pass these in: -teCalc.addObservations(destArray, sourceArray); +teCalc.addObservations(sourceArray, destArray); fprintf('For copied source, result should be close to 1 bit : '); result = teCalc.computeAverageLocalOfObservations() teCalc.initialise(); -teCalc.addObservations(destArray, sourceArray2); +teCalc.addObservations(sourceArray2, destArray); fprintf('For random source, result should be close to 0 bits: '); result2 = teCalc.computeAverageLocalOfObservations() diff --git a/demos/octave/example5TeBinaryMultivarTransfer.m b/demos/octave/example5TeBinaryMultivarTransfer.m index bd1d3d8..ac79a11 100755 --- a/demos/octave/example5TeBinaryMultivarTransfer.m +++ b/demos/octave/example5TeBinaryMultivarTransfer.m @@ -20,13 +20,13 @@ teCalc.initialise(); % We need to construct the joint values of the dest and source before we pass them in, % and need to use the matrix conversion routine when calling from Matlab/Octave: mUtils= javaObject('infodynamics.utils.MatrixUtils'); -teCalc.addObservations(mUtils.computeCombinedValues(octaveToJavaIntMatrix(destArray), 2), ... - mUtils.computeCombinedValues(octaveToJavaIntMatrix(sourceArray), 2)); +teCalc.addObservations(mUtils.computeCombinedValues(octaveToJavaIntMatrix(sourceArray), 2), ... + mUtils.computeCombinedValues(octaveToJavaIntMatrix(destArray), 2)); fprintf('For source which the 2 bits are determined from, result should be close to 2 bits : '); result = teCalc.computeAverageLocalOfObservations() teCalc.initialise(); -teCalc.addObservations(mUtils.computeCombinedValues(octaveToJavaIntMatrix(destArray), 2), ... - mUtils.computeCombinedValues(octaveToJavaIntMatrix(sourceArray2), 2)); +teCalc.addObservations(mUtils.computeCombinedValues(octaveToJavaIntMatrix(sourceArray2), 2), ... + mUtils.computeCombinedValues(octaveToJavaIntMatrix(destArray), 2)); fprintf('For random source, result should be close to 0 bits in theory: '); result2 = teCalc.computeAverageLocalOfObservations() fprintf('\nThe result for random source is inflated towards 0.3 due to finite observation length (%d).\nOne can verify that the answer is consistent with that from a\nrandom source by checking: teCalc.computeSignificance(1000); ans.pValue\n', teCalc.getNumObservations()); diff --git a/demos/python/example1TeBinaryData.py b/demos/python/example1TeBinaryData.py index 4823b46..f2401a0 100755 --- a/demos/python/example1TeBinaryData.py +++ b/demos/python/example1TeBinaryData.py @@ -20,10 +20,10 @@ teCalcClass = JPackage("infodynamics.measures.discrete").TransferEntropyCalculat teCalc = teCalcClass(2,1) teCalc.initialise() # Since we have simple arrays of ints, we can directly pass these in: -teCalc.addObservations(destArray, sourceArray) +teCalc.addObservations(sourceArray, destArray) print("For copied source, result should be close to 1 bit : %.4f" % teCalc.computeAverageLocalOfObservations()) teCalc.initialise() -teCalc.addObservations(destArray, sourceArray2) +teCalc.addObservations(sourceArray2, destArray) print("For random source, result should be close to 0 bits: %.4f" % teCalc.computeAverageLocalOfObservations()) shutdownJVM() diff --git a/demos/python/example5TeBinaryMultivarTransfer.py b/demos/python/example5TeBinaryMultivarTransfer.py index 89a1f37..1c66e0d 100755 --- a/demos/python/example5TeBinaryMultivarTransfer.py +++ b/demos/python/example5TeBinaryMultivarTransfer.py @@ -28,13 +28,13 @@ teCalc.initialise() # We need to construct the joint values of the dest and source before we pass them in, # and need to use the matrix conversion routine when calling from Matlab/Octave: mUtils= JPackage('infodynamics.utils').MatrixUtils -teCalc.addObservations(mUtils.computeCombinedValues(destArray, 2), \ - mUtils.computeCombinedValues(sourceArray, 2)) +teCalc.addObservations(mUtils.computeCombinedValues(sourceArray, 2), \ + mUtils.computeCombinedValues(destArray, 2)) result = teCalc.computeAverageLocalOfObservations() print('For source which the 2 bits are determined from, result should be close to 2 bits : %.3f' % result) teCalc.initialise() -teCalc.addObservations(mUtils.computeCombinedValues(destArray, 2), \ - mUtils.computeCombinedValues(sourceArray2, 2)) +teCalc.addObservations(mUtils.computeCombinedValues(sourceArray2, 2), \ + mUtils.computeCombinedValues(destArray, 2)) result2 = teCalc.computeAverageLocalOfObservations() print('For random source, result should be close to 0 bits in theory: %.3f' % result2) print('The result for random source is inflated towards 0.3 due to finite observation length (%d). One can verify that the answer is consistent with that from a random source by checking: teCalc.computeSignificance(1000); ans.pValue\n' % teCalc.getNumObservations())