DTWv1, v2 { | //where the vectors v1=(a1,…,an), v2=(b1,…,bm) are the time series with n and m | time points | Let a two dimensional data matrix S be the store of similarity measures | such that S0,…,n, 0,…,m, and i, j, are loop index, cost is an integer. | // initialize the data matrix | S0, 0 0 | FOR i 1 to m DO LOOP | S0, i ∞ | END | FOR i 1 to n DO LOOP | Si, 0 ∞ | END | // Using pairwise method, incrementally fill in the similarity matrix | with the differences of the two time series | FOR i 1 to n DO LOOP | FOR j 1 to m DO LOOP | // function to measure the distance between the two points | cost dv1i, v2j | S[i, j] cost + MINSi-1, j, increment | Si, j−1, decrement | Si-1, j−1 match | END | END | Return Sn, m |
}
|
|