warpArea

dtw.warpArea(d)

Compute Warping Path Area

Compute the area between the warping function and the diagonal (no-warping) path, in unit steps.

Details

Above- and below- diagonal unit areas all count plus one (they do not cancel with each other). The “diagonal” goes from one corner to the other of the possibly rectangular cost matrix, therefore having a slope of M/N, not 1, as in [slantedBandWindow()].

The computation is approximate: points having multiple correspondences are averaged, and points without a match are interpolated. Therefore, the area can be fractionary.

Parameters:

d – an object of class dtw

Return type:

The area, not normalized by path length or else.

Notes

There could be alternative definitions to the area, including considering the envelope of the path.

Examples

>>> from dtw import *
>>> ds = dtw( [1,2,3,4], [1,2,3,4,5,6,7,8]);
>>> import matplotlib.pyplot as plt;
... ds.plot(); plt.plot([0,2.3,4.7,7])          
>>> warpArea(ds)                                

The area is not the expected result due different assumptions used in the scipy.interpolate.interp1d funtion.

>>> ## Result: 6
>>> ##  index 2 is 2 while diag is 3_3  (+1_3)
>>> ##        3    3               5_7  (+2_7)
>>> ##        4   4:8 (avg to 6)    8   (+2  )
>>> ##                                 --------
>>> ##                                     6