How does DTW penalize stretching ?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Bert
il 4 Ott 2016
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!
Più risposte (1)
Greg Dionne
il 21 Ott 2016
Have you tried EDR? It penalizes stretching.
It might be helpful to post the data you are trying to compare.
0 Commenti
Vedere anche
Categorie
Scopri di più su Spectral Measurements in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!