Standard DTW as described in [Muller07], using the Manhattan distance (absolute value of the difference) as local cost measure.
Parameters : |
|
---|---|
Returns : |
|
[Muller07] | (1, 2) M Muller. Information Retrieval for Music and Motion. Springer, 2007. |
Example
Reproducing the Fig. 2 example in [Salvador04].
>>> import mlpy
>>> import matplotlib.pyplot as plt
>>> import matplotlib.cm as cm
>>> x = [0,0,0,0,1,1,2,2,3,2,1,1,0,0,0,0]
>>> y = [0,0,1,1,2,2,3,3,3,3,2,2,1,1,0,0]
>>> dist, cost, path = mlpy.dtw_std(x, y, dist_only=False)
>>> dist
0.0
>>> fig = plt.figure(1)
>>> ax = fig.add_subplot(111)
>>> plot1 = plt.imshow(cost.T, origin='lower', cmap=cm.gray, interpolation='nearest')
>>> plot2 = plt.plot(path[0], path[1], 'w')
>>> xlim = ax.set_xlim((-0.5, cost.shape[0]-0.5))
>>> ylim = ax.set_ylim((-0.5, cost.shape[1]-0.5))
>>> plt.show()
[Salvador04] | S Salvador and P Chan. FastDTW: Toward Accurate Dynamic Time Warping in Linear Time and Space. 3rd Wkshp. on Mining Temporal and Sequential Data, ACM KDD ‘04, 2004. |
Subsequence DTW as described in [Muller07], assuming that the length of y is much larger than the length of x and using the Manhattan distance (absolute value of the difference) as local cost measure.
Returns the subsequence of y that are close to x with respect to the minimum DTW distance.
Parameters : |
|
---|---|
Returns : |
|