fastdtw icon indicating copy to clipboard operation
fastdtw copied to clipboard

Changing radius has no effect

Open dmitra79 opened this issue 6 years ago • 4 comments

Please see the example below - changing radius produces no change in distance function, which doesn't make sense for this example. It seems like radius parameter is ignored....

N = 100
idx = np.linspace(0, 2*np.pi, N)
T1 = np.cos(idx)
Q1 = np.sin(idx) + np.array(np.random.uniform(low=0,high=1,size=(N,)))/10

for r in range(1,10):
    print(5*r)
    dist_f1, path_f1 = fastdtw(Q1, T1, dist=euclidean, radius=r)
    print(dist_f1)

dmitra79 avatar Jul 22 '18 17:07 dmitra79

Haven't ran this code myself so can't say for sure, but is this because the optimal path is within 1 cell away from the diagonal? I.e. the algorithm is computing the whole distance matrix but the optimal path is close enough to the diagonal that it is irrelevant

jlc-christie avatar Sep 05 '18 13:09 jlc-christie

The optimal path is not close to diagonal (also, I've tried this with other packages and changing radius does make a difference)

dmitra79 avatar Sep 05 '18 14:09 dmitra79

I just repeated this and plotted the path and all paths are identical and clearly don't use the specified radius, e.g. radius 1 through 9 all look like the image below, which clearly has a radius greater than 1. image

jlc-christie avatar Sep 05 '18 14:09 jlc-christie

Could this be caused by the fact that the radius is applied relative to the downsampled time series? For example, if you have 2 time series of length 90 and you downsample them until they only have a length of 3 then and your path suggest to go one step away from the diagonal then this one step will eventually look like the radius was 30 after you've upsampled the path again.

Without being the develop or having any deep knowledge it looks like the radius is applied relative to the path that was found by DTW on the downsampled time series.

flekschas avatar Mar 18 '19 19:03 flekschas