DynamicTimeWarping / dtw-python

Python port of R's Comprehensive Dynamic Time Warp algorithms package
https://dynamictimewarping.github.io
GNU General Public License v3.0
279 stars 35 forks source link

Inconsistent distance to Matlab #63

Closed castdice closed 1 year ago

castdice commented 1 year ago

I am trying to use the package in my work but found the dtw distance computed by this package is different from some other version of dtw implementations. Here is the code snippet:

from dtw import *
x=[0, 1, 2, 3, 4, 5, 6, 7, 8]
y=[1, 2, 3, 4, 5, 6, 7, 7, 10]
alignments = dtw(x, y)
dtw_dist = alignments.distance
print("DTW package result: {}".format(dtw_dist))

and the output is

DTW package result: 4.0

However, the output of matlab is:

x=[0, 1, 2, 3, 4, 5, 6, 7, 8]
y=[1, 2, 3, 4, 5, 6, 7, 7, 10]
dtw(x, y)

ans = 3

The default distance for both functions is euclidean. I am new to this field. Did I do something wrong? Thank you for your patience.

tonigi commented 1 year ago

See FAQ 1 and 2 here https://dynamictimewarping.github.io/faq/

castdice commented 1 year ago

That really helps. Thank you!