Matrix-Profile icon indicating copy to clipboard operation
Matrix-Profile copied to clipboard

MatrixProfile.stamp does not give deterministic results for self-join case

Open barrybecker4 opened this issue 6 years ago • 2 comments

For the versions of stamp and stmp that take a query parameter, I see that the results are the same between them. However for the self-join case (no query provided), then the results for stamp are non-deterministic. I'm sure that this has to do with Random not using a seed, but shouldn't the result be the same even if the indices are processed in a different order each time?

When I run this test, I get different results for the second part of the pair nearly every time.

   INDArray shortTargetSeries = Nd4j.create(new double[]{0.0, 6.0, -1.0, 2.0, 3.0, 1.0, 4.0}, new int[]{1, 7});

   @Test
    public void testMatrixProfileSelfJoinStampWindow4() {
        int window = 4;
        Pair<INDArray, INDArray>expectedResultWhenSelfJoin = new Pair<>(
                Nd4j.create(new double[]{1.7308, POSITIVE_INFINITY, POSITIVE_INFINITY, 1.7308}, new int[]{1, 4}),
                Nd4j.create(new double[]{3.0000,    2.0000,    2.0000,     0}, new int[]{1, 4})
        );
        Pair<INDArray, INDArray> pair = matrixProfile.stamp(shortTargetSeries, window);
        assertEquals(expectedResultWhenSelfJoin.toString(), pair.toString());
    }

The first part of the pair in the result is always the same, but the second part of the pair is random. It is of the form [ 3.0000, x, x, 0]] where x is 0, 1, 2, or 3. Why? Is this a bug or my misunderstanding?

barrybecker4 avatar Nov 20 '18 15:11 barrybecker4