How does DTW penalize stretching ?

6 次查看(过去 30 天)
The DTW function from Signal Processing Toolbox seems to penalize stretching of a Time Series/Signal. Can i switch that off or define my own penalties/weights ?

采纳的回答

Bert
Bert 2016-10-4
hi,
I believe you misunderstood the DTW principal. DTW does directly penalizes stretching in the signals, as intended. The best way to show this is by some examples.
Try following input were the stretching is done by repeating some samples (depending on the application: but might not be the stretching normally seen, e.g. speech signals):
s1 = [1 4 7]';
s2 = [1 4 4 7]';
The error matrix will be (absolute error):
error = [0 3 6;...
3 0 3;...
3 0 3;...
6 3 0]; % s1 horizontally, s2 vertically
So there is a path from upper left to bottom right (taking horizontally, vertically or diagonal steps) with only zero penalties and thus the DTW distance will be zero! And so, DTW does not penalize this kind of stretching.
But, now consider a second example:
s1 = [1 4 7];
s2 = [1 3 5 7];
This is stretched as well. However, this is now done by interpolation (which might be a more normal kind of stretching, e.g. speech) the error matrix will now become:
error = [0 3 6;...
3 1 3;...
4 1 2;...
6 3 0]; % s1 horizontally, s2 vertically
Now there doesn't exist a path with only zeros! the minimum DTW distance (the sum of all errors on a path from upper left to bottom right) will be 2 in this case.
So: However the signals are stretched versions of each other, DTW didn't penalize the stretching itself. But DTW penalized that both signals have different sample values. Therefore, you cannot penalize this stretch any differently as differences in the signals not due to a stretch.
Hope this helps!
  1 个评论
Mac Fuirdmith
Mac Fuirdmith 2016-10-4
Ok, thanks for that answer. So there should be no penalties for stretching. Would it be possible to include such penalties nonetheless ? (without further workaround like looking up the matching paths and counting stretches)

请先登录,再进行评论。

更多回答(1 个)

Greg Dionne
Greg Dionne 2016-10-21
Have you tried EDR? It penalizes stretching.
It might be helpful to post the data you are trying to compare.

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by