| Algorithm 2: Pseudo-code of the algorithm for forming principle components. |
| DTW (A, G) { // where the vectors A = (a1, …, an), G = (g1, …, gm) are the time series data collected from accelerometer and gyroscope with n and m data points, respectively. Define M [0, …, n, 0, …, m] as a two-dimensional data matrix. It stores the similarity measures between two time series. / / Data matrix initialization M [0, 0]: = 0 For i = 0 to m Step 1 Do: M [0, i]: = Infinity End For i: = 1 to n Step 1 Do: M [i, 0]: = Infinity End // Compute the similarity measures between the two time series and store them in M [n,m] For i :=1 to n Step 1 Do: For j : =1 to m Step 1 Do: // Evaluate the similarity of the two points diff := M [i, j] := diff +Min (M[i-1, j], M [i, j-1], M [i-1, j-1]) End End Return M [n, m] } |