Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Dynamic Time Warping

• The DTW is an elastic matching algorithm that is used to compare


time series data, that are to be matched.

• To align two sequences under certain constraints, such that the distance
between these two sequences is as small as possible.
• Distance between Same-length Sequences

 n
  xi  yi , p  1
1
 i 1
 n
p p 
Lp  norm( x, y )     xi  yi     n
 
 i i , p 2
2
 i 1  x  y
i 1

max xi  yi , p  
 i

x   x1 , x2 , x3 , x4 , x5 , x6 , x7 , x8 , x9 

y   y1 , y2 , y3 , y4 , y5 , y6 , y7 , y8 , y9 
x   x1 , x2 , xm  , y   y1 , y2 , yn 
We want to find an alignment path  p , q  ,  p , q  ,  p , q 
1 1 2 2 k k

(subject to the alignment constraints), such that the distance along the
path is minimized:

 x 
k 2
dist ( x, y )  min  yqi ,
 pi , qi , i 1 k
i 1
pi

with the bounary conditions:


Anchored beginning:  p1 , q1   1,1

 Anchored end:  pk , qk    m, n 
Temporal constraints
p1  p2   pk , q1  q2   qk

• 1-to-1, 1-to-many, or many-to-1 mapping


• No skip-over

Alignment path =
x1 x2 x3 x4 x5 1,1 ,  2, 2 ,  2,3 , 3, 4  , 3,5 ,  4, 6  , 5, 7  , 5,8
y1 y2 y3 y4 y5 y6 y7 y8
Di, j 
Di  1, j 

x, y: input vector/matrix
Di, j  1 Local paths: 0-45-90 degrees
Di  1, j  1

j DTW formulation:

1. Optimum-value function D(i, j ):


y(j) D(i, j ) The DTW distance between x(1: i) and y(1: j )
2. Recurrent equation for D(i, j ) :
 D(i, j  1) 
 
D(i, j )  x(i )  y ( j )  min  D(i  1, j  1)  ,
 D(i  1, j ) 
 
with D(1,1)  x(1)  y (1) .
3. Answer  D(len( x), len( y ))

x(i-1) x(i) i

You might also like