1mlib_SignalDTWScalar_F32(3MmLeIdBi)aLib Library Functmiloinbs_SignalDTWScalar_F32(3MLIB)
2
3
4
6 mlib_SignalDTWScalar_F32 - perform dynamic time warping on scalar data
7
9 cc [ flag... ] file... -lmlib [ library... ]
10 #include <mlib.h>
11
12 mlib_status mlib_SignalDTWScalar_F32(mlib_d64 *dist,
13 const mlib_f32 *dobs, mlib_s32 lobs, void *state);
14
15
17 The mlib_SignalDTWScalar_F32() function performs dynamic time warping
18 on scalar data.
19
20
21 Assume the reference data are
22
23 r(y), y=1,2,...,N
24
25
26
27 and the observed data are
28
29 o(x), x=1,2,...,M
30
31
32
33 the dynamic time warping is to find a mapping function (a path)
34
35 p(i) = {px(i),py(i)}, i=1,2,...,Q
36
37
38
39 with the minimum distance.
40
41
42 In K-best paths case, K paths with the K minimum distances are
43 searched.
44
45
46 The distance of a path is defined as
47
48 Q
49 dist = SUM d(r(py(i)),o(px(i))) * m(px(i),py(i))
50 i=1
51
52
53
54 where d(r,o) is the dissimilarity between data point/vector r and data
55 point/vector o; m(x,y) is the path weighting coefficient associated
56 with path point (x,y); N is the length of the reference data; M is the
57 length of the observed data; Q is the length of the path.
58
59
60 Using L1 norm (sum of absolute differences)
61
62 L-1
63 d(r,o) = SUM |r(i) - o(i)|
64 i=0
65
66
67
68 Using L2 norm (Euclidean distance)
69
70 L-1
71 d(r,o) = SQRT { SUM (r(i) - o(i))**2 }
72 i=0
73
74
75
76 where L is the length of each data vector.
77
78
79 To scalar data where L=1, the two norms are the same.
80
81 d(r,o) = |r - o| = SQRT {(r - o)**2 }
82
83
84
85 The constraints of dynamic time warping are:
86
87 1. Endpoint constraints
88
89 px(1) = 1
90 1 ≤ py(1) ≤ 1 + delta
91
92 and
93
94 px(Q) = M
95 N-delta ≤ py(Q) ≤ N
96
97
98 2. Monotonicity Conditions
99
100 px(i) ≤ px(i+1)
101 py(i) ≤ py(i+1)
102
103
104 3. Local Continuity Constraints
105
106 See Table 4.5 on page 211 in Rabiner and Juang's book.
107
108 Itakura Type:
109
110 py
111 |
112 *----*----*
113 |p4 |p1 |p0
114 | | |
115 *----*----*
116 | |p2 |
117 | | |
118 *----*----*-- px
119 p3
120
121 Allowable paths are
122
123 p1->p0 (1,0)
124 p2->p0 (1,1)
125 p3->p0 (1,2)
126
127 Consecutive (1,0)(1,0) is disallowed. So path p4->p1->p0 is
128 disallowed.
129
130 4. Global Path Constraints
131
132 Due to local continuity constraints, certain portions of the
133 (px,py) plane are excluded from the region the optimal warp‐
134 ing path can traverse. This forms global path constraints.
135
136 5. Slope Weighting
137
138 See Equation 4.150-3 on page 216 in Rabiner and Juang's
139 book.
140
141
142 A path in (px,py) plane can be represented in chain code. The value of
143 the chain code is defined as following.
144
145 ============================
146 shift ( x , y ) | chain code
147 ----------------------------
148 ( 1 , 0 ) | 0
149 ( 0 , 1 ) | 1
150 ( 1 , 1 ) | 2
151 ( 2 , 1 ) | 3
152 ( 1 , 2 ) | 4
153 ( 3 , 1 ) | 5
154 ( 3 , 2 ) | 6
155 ( 1 , 3 ) | 7
156 ( 2 , 3 ) | 8
157 ============================
158
159 py
160 |
161 * 8 7 *
162 |
163 * 4 * 6
164 |
165 1 2 3 5
166 |
167 x--0--*--*-- px
168
169
170
171 where x marks the start point of a path segment, the numbers are the
172 values of the chain code for the segment that ends at the point.
173
174
175 In following example, the observed data with 11 data points are mapped
176 into the reference data with 9 data points
177
178 py
179 |
180 9 | * * * * * * * * * *-*
181 | /
182 | * * * * * * * *-* * *
183 | /
184 | * * * * * * * * * * *
185 | /
186 | * * * * *-* * * * * *
187 | /
188 | * * * * * * * * * * *
189 | |
190 | * * * * * * * * * * *
191 | /
192 | * * * * * * * * * * *
193 | /
194 | * * * * * * * * * * *
195 | /
196 1 | * * * * * * * * * * *
197 |
198 +------------------------ px
199 1 11
200
201
202
203 The chain code that represents the path is
204
205 (2 2 2 1 2 0 2 2 0 2 0)
206
207
208
209 See Fundamentals of Speech Recognition by Lawrence Rabiner and Biing-
210 Hwang Juang, Prentice Hall, 1993.
211
213 The function takes the following arguments:
214
215 dist The distance of the optimal path.
216
217
218 dobs The observed data array.
219
220
221 lobs The length of the observed data array.
222
223
224 state Pointer to the internal state structure.
225
226
228 The function returns MLIB_SUCCESS if successful. Otherwise it returns
229 MLIB_FAILURE.
230
232 See attributes(5) for descriptions of the following attributes:
233
234
235
236
237 ┌─────────────────────────────┬─────────────────────────────┐
238 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
239 ├─────────────────────────────┼─────────────────────────────┤
240 │Interface Stability │Committed │
241 ├─────────────────────────────┼─────────────────────────────┤
242 │MT-Level │MT-Safe │
243 └─────────────────────────────┴─────────────────────────────┘
244
246 mlib_SignalDTWScalarInit_F32(3MLIB), mlib_SignalDTWScalar_F32(3MLIB),
247 mlib_SignalDTWScalarPath_F32(3MLIB), mlib_SignalDTWScalar‐
248 Free_F32(3MLIB), attributes(5)
249
250
251
252SunOS 5.11 23 May 2007 mlib_SignalDTWScalar_F32(3MLIB)