MCPcopy Create free account
hub / github.com/DynamicTimeWarping/dtw-python / mvmStepPattern

Function mvmStepPattern

dtw/mvm.py:26–111  ·  view source on GitHub ↗

Minimum Variance Matching algorithm Step patterns to compute the Minimum Variance Matching (MVM) correspondence between time series **Details** The Minimum Variance Matching algorithm (1) finds the non-contiguous parts of reference which best match the query, allowing for arbitrarily long “stretc

(elasticity=20)

Source from the content-addressed store, hash-verified

24import numpy
25
26def mvmStepPattern(elasticity=20):
27 # IMPORT_RDOCSTRING mvmStepPattern
28 """Minimum Variance Matching algorithm
29
30Step patterns to compute the Minimum Variance Matching (MVM)
31correspondence between time series
32
33**Details**
34
35The Minimum Variance Matching algorithm (1) finds the non-contiguous
36parts of reference which best match the query, allowing for arbitrarily
37long “stretches” of reference to be excluded from the match. All
38elements of the query have to be matched. First and last elements of the
39query are anchored at the boundaries of the reference.
40
41The ``mvmStepPattern`` function creates a ``stepPattern`` object which
42implements this behavior, to be used with the usual [dtw()] call (see
43example). MVM is computed as a special case of DTW, with a very large,
44asymmetric-like step pattern.
45
46The ``elasticity`` argument limits the maximum run length of reference
47which can be skipped at once. If no limit is desired, set ``elasticity``
48to an integer at least as large as the reference (computation time grows
49linearly).
50
51Parameters
52----------
53elasticity :
54 integer: maximum consecutive reference elements skippable
55
56Returns
57-------
58
59A step pattern object.
60
61References
62----------
63
64Latecki, L. J.; Megalooikonomou, V.; Wang, Q. & Yu, D. *An elastic
65partial shape matching technique* Pattern Recognition, 2007, 40,
663069-3080.
67`doi:10.1016/j_patcog.2007.03.004 <https://doi.org/10.1016/j_patcog.2007.03.004>`__
68
69Examples
70--------
71
72>>> import numpy as np
73>>> from dtw import *
74
75The hand-checkable example given in Fig. 5, ref. [1] above
76
77>>> diffmx = np.array(
78... [[ 0, 1, 8, 2, 2, 4, 8 ],
79... [ 1, 0, 7, 1, 1, 3, 7 ],
80... [ -7, -6, 1, -5, -5, -3, 1 ],
81... [ -5, -4, 3, -3, -3, -1, 3 ],
82... [ -7, -6, 1, -5, -5, -3, 1 ]], dtype=np.double )
83

Callers

nothing calls this directly

Calls 1

StepPatternClass · 0.90

Tested by

no test coverage detected