How does DTW penalize stretching ?

조회 수: 4 (최근 30일)
Mac Fuirdmith
Mac Fuirdmith 2016년 10월 4일
답변: Greg Dionne 2016년 10월 21일
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에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by