0

I want to find similar shapes in time series using stumpy. However there seems to be some kind of special treatment of values that I do not understand.

Let me give you an example:

import numpy as np
import matplotlib.pyplot as plt
import stumpy
ssss=105*np.ones(800)
ssss[:50]=100
m = 210
mp = stumpy.stump(ssss, m=m)

plt.plot(ssss, color="blue")
plt.plot(mp[:,0], color="orange")

Results in

wrong distance plot

But clearly there are many parts where there is a perfect match after the jump, so the orange line, the distance, should be 0. Why is that not the case?

Surprisingly, if you change the 100 to 101 you get the result you would expect:

import numpy as np
import matplotlib.pyplot as plt
import stumpy
ssss=105*np.ones(800)
ssss[:50]=101
m = 210
mp = stumpy.stump(ssss, m=m)

plt.plot(ssss, color="blue")
plt.plot(mp[:,0], color="orange")

distance correct

What is an explanation for that?

Noskario
  • 378
  • 1
  • 9
  • 1
    Can you please provide the version number that you are using? Have you tried the latest development version? Is this still a problem? – slaw Jul 21 '23 at 11:26

1 Answers1

2

I tried your first code using the latest development version.

import numpy as np
import matplotlib.pyplot as plt
import stumpy

T = 105 *  np.ones(800)
T[:50] = 100
m = 210

mp = stumpy.stump(T, m=m)

plt.plot(T, color="blue")
plt.plot(mp[:,0], color="orange")
plt.show()

and I get this:

enter image description here

which makes sense I think. So, I suggest that you start fresh and install stumpy again and check the result.

Regarding your second question: If I change 100 to 101, I get the same figure as above [which makes sense I believe when the param normalize is set to True (default)]

Nima S
  • 203
  • 2
  • 13
  • 2
    When you say "latest version", is that the latest release or the latest development version? – slaw Jul 21 '23 at 11:25
  • @slaw Thank you for pointing that out! I revised the answer – Nima S Jul 21 '23 at 11:33
  • It might also be useful to add a comment as to why/how the behavior in the original post was "corrected" in the latest development version. This may help others to recognize which version has fixed this issue and provide further context on what caused the original "bad" behavior. – slaw Jul 21 '23 at 15:14
  • @slaw I think I first need to get the info regarding the version number used tp create the result in the original post. Or, if I get a chance, I may write a program to install different versions automatically and see where there is a change in the output for the input provided in the first case :) – Nima S Jul 22 '23 at 21:59