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 ?
0 个评论
采纳的回答
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 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!