You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// MPDist computes the matrix profile distance measure between a and b with a
195
226
// subsequence window of m.
196
-
funcMPDist(a, b []float64, mint, o*MPOptions) (float64, error) {
197
-
mp, err:=New(a, b, m)
227
+
funcMPDist(a, b []float64, wint, o*MPDistOpts) (float64, error) {
228
+
ifo==nil {
229
+
o=NewMPDistOpts()
230
+
}
231
+
232
+
mp, err:=New(a, b, w)
198
233
iferr!=nil {
199
234
return0, err
200
235
}
201
236
202
-
iferr=mp.Compute(o); err!=nil {
237
+
iferr=mp.Compute(o.Opts); err!=nil {
203
238
return0, nil
204
239
}
240
+
241
+
mpab, mpba, err:=mp.ApplyAV()
242
+
iferr!=nil {
243
+
return0, nil
244
+
}
245
+
205
246
thresh:=0.05
206
247
k:=int(thresh*float64(len(a)+len(b)))
207
-
mpABBASize:=len(mp.MP) +len(mp.MPB)
248
+
mpABBASize:=len(mpab) +len(mpba)
208
249
209
250
ifk<mpABBASize {
210
251
varlowestMPsmpVals
211
252
heap.Init(&lowestMPs)
212
-
for_, d:=rangemp.MP {
253
+
for_, d:=rangempab {
213
254
// since this is a max heap and correlations go from 0-1 we need high correlations
214
255
// to stay in the heap with the poorest correlation at the root.
215
256
if!mp.Opts.Euclidean {
@@ -225,7 +266,7 @@ func MPDist(a, b []float64, m int, o *MPOptions) (float64, error) {
225
266
}
226
267
}
227
268
228
-
for_, d:=rangemp.MPB {
269
+
for_, d:=rangempba {
229
270
// since this is a max heap and correlations go from 0-1 we need high correlations
230
271
// to stay in the heap with the poorest correlation at the root.
231
272
if!mp.Opts.Euclidean {
@@ -289,22 +330,22 @@ const (
289
330
AlgoMPXAlgo="mpx"
290
331
)
291
332
292
-
// MPOptions are parameters to vary the algorithm to compute the matrix profile.
293
-
typeMPOptionsstruct {
333
+
// MPOpts are parameters to vary the algorithm to compute the matrix profile.
334
+
typeMPOptsstruct {
294
335
AlgorithmAlgo`json:"algorithm"`// choose which algorithm to compute the matrix profile
295
336
Samplefloat64`json:"sample_pct"`// only applicable to algorithm STAMP
296
337
Parallelismint`json:"parallelism"`
297
338
Euclideanbool`json:"euclidean"`// defaults to using euclidean distance instead of pearson correlation for matrix profile
298
339
RemapNegCorrbool`json:"remap_negative_correlation"`// defaults to no remapping. This is used so that highly negatively correlated sequences will show a low distance as well.
299
340
}
300
341
301
-
// NewMPOpts returns a default MPOptions
302
-
funcNewMPOpts() *MPOptions {
342
+
// NewMPOpts returns a default MPOpts
343
+
funcNewMPOpts() *MPOpts {
303
344
p:=runtime.NumCPU() *2
304
345
ifp<1 {
305
346
p=1
306
347
}
307
-
return&MPOptions{
348
+
return&MPOpts{
308
349
Algorithm: AlgoMPX,
309
350
Sample: 1.0,
310
351
Parallelism: p,
@@ -313,7 +354,7 @@ func NewMPOpts() *MPOptions {
313
354
}
314
355
315
356
// Compute calculate the matrixprofile given a set of input options.
0 commit comments