## Rule of thumb for choosing DTW over other distances for time series analysis

I recently received an e-mail from a former student of a course about time series analysis that I teach at ISAE asking me about dynamic time warping (DTW). Since this is a frequently asked question, I thought it would be useful to write my answer here for further reference.

The classical question many people ask when first introduced to DTW is when to choose DTW instead of other distances for time series analysis.

People usually quickly grasp the advantages of DTW over the Euclidean distance, since the latter needs perfect temporal alignment between the 2 time series being compared. However, many people get confused when they have in mind linear correlation’s invariance to scale changes.

Linear correlation is indeed invariant to scale, but it still needs that the samples of the time series are perfectly aligned. To put it simply, this invariance applies to the values of the samples and not to their temporal position.

DTW does not have this invariance, but, as for any other distance, it can be obtained by normalizing the time series before computing the distance (subtraction of the mean and division by the standard deviation, for instance). On the other hand, DTW is robust to temporal distortions, like temporal shifts of the samples.

Another important property of DTW is that it can be applied to pairs of time series having different number of samples. This can be very useful in applications where some samples can be considered invalid or are censored, like for instance cloudy pixels in optical satellite image time series.

Therefore, it is the job of the user to choose the one which best fits the problem at hand.

For more information about DTW, you can check FranÃ§ois Petitjean’s web site where you can get an interesting paper about the use of DTW for remote sensing image time series1 and also Java code implementing DTW.

## Footnotes:

1

F. Petitjean, J. Inglada & P. GanÃ§arski. “Satellite Image Time Series Analysis under Time Warping”. IEEE Transactions on Geoscience and Remote Sensing, 2012, Vol. 50, Num. 8, pp. 3081-3095. doi:10.1109/TGRS.2011.2179050