Professional Documents
Culture Documents
Goal
To align two sequences under certain
constraints, such that the distance
between these two sequences is as small
as possible.
Method
Dynamic programming
-2-
Distance between Same-length Sequences
x x1 , x2 , xn and y y1 , y2 , yn
Distance between
n
xi yi , p 1
1
i 1
n p p
Lp norm( x, y ) xi yi n
xi yi , p 2
2
i 1
i 1
max xi yi , p
i
Alignment x x1 , x2 , x3 , x4 , x5 , x6 , x7 , x8 , x9
y y1 , y2 , y3 , y4 , y5 , y6 , y7 , y8 , y9
-3-
Distance between Different-length Sequences
x x1 , x2 , xm , y y1 , y2 , yn
(subject to the alignment constraints), such that the distance along the
path is minimized:
k
x
2
dist ( x, y ) min pi yqi ,
pi , qi , i 1k i 1
-4-
Alignment Constraints: Type 1
Temporal constraints
p1 p2 pk , q1 q2 qk
Other alignment constraints
One-to-one mapping
No consecutive skip-over
Alignment path =
x1 x2 x3 x4 x5
1,1 , 2,3 , 3,5 , 4, 6 , 5,8
y1 y2 y3 y4 y5 y6 y7 y8
-5-
Alignment Constraints: Type 2
Temporal constraints
p1 p2 pk , q1 q2 qk
Other alignment constraints
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
-6-
Type-1 DTW: Table Fillup
x, y: input vector/matrix
j Local paths: 27-45-63 degrees
DTW formulation:
D (i, j ) 1. Optimum-value function D(i, j ):
y(j)
y(j-1) The DTW distance between x(1: i ) and y (1: j )
2. Recurrent equation for D(i, j ) :
D(i 1, j 2)
D(i, j ) x(i ) y ( j ) min D(i 1, j 1) ,
D(i 2, j 1)
with D (1,1) x(1) y (1) .
x(i-1) x(i)
3. Answer D(len( x), len( y ))
i
-7-
Type-2 DTW: Table Fillup
x, y: input vector/matrix
j Local paths: 0-45-90 degrees
DTW formulation:
y(j) D (i, j ) 1. Optimum-value function D(i, j ):
y(j-1) 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) .
x(i-1) x(i) i 3. Answer D(len( x), len( y ))
-8-
Local Path Constraints
Type 1: Type 2:
27-45-63 local paths 0-45-90 local paths
D i, j
D i, j
D i 1, j
D i 2, j 1 D i 1, j 1
D i, j 1
D i 1, j 1
D i 1, j 2
D (i 1, j 2) D(i, j 1)
min D(i 1, j 1) min D(i 1, j 1)
D (i 2, j 1) D(i 1, j )
-9-
Path Penalty for Type-1 DTW
D(i 1, j 2) 0
D i 1, j 1
D(i, j ) x(i ) y ( j ) min D(i 1, j 1) D i 2, j 1
D(i 2, j 1)
D i 1, j 2
-10-
Path Penalty for Type-2 DTW
-11-
Other Minutes about DTW
Typical applications
Speech recognition: MFCC matrices as inputs
(where x(i) is the MFCC vector of frame i)
Query by singing/humming: Pitch vectors as
inputs (where x(i) is the pitch value of frame i)
Abundant variants for various applications
Recurrent formulas
Local path constraints
-12-
Applications
Applications of DTW
DTW for speech recognition
DTW for query by singing/humming
-13-