msm_distance#

msm_distance(x: ndarray, y: ndarray, window: float = None, independent: bool = True, c: float = 1.0) float[source]#

Compute the MSM distance between two time series.

This metric uses as building blocks three fundamental operations: Move, Split, and Merge. A Move operation changes the value of a single element, a Split operation converts a single element into two consecutive elements, and a Merge operation merges two consecutive elements into one. Each operation has an associated cost, and the MSM distance between two time series is defined to be the cost of the cheapest sequence of operations that transforms the first time series into the second one.

Parameters:
x: np.ndarray, of shape (n_channels, n_timepoints) or (n_timepoints,)

First time series.

y: np.ndarray, of shape (m_channels, m_timepoints) or (m_timepoints,)

Second time series.

window: float, default=None

The window to use for the bounding matrix. If None, no bounding matrix is used.

independent: bool, defaults=True

Whether to use the independent or dependent MSM distance. The default is True (to use independent).

c: float, defaults=1.

Cost for split or merge operation. Default is 1.

Returns:
float

MSM distance between x and y.

Raises:
ValueError

If x and y are not 1D or 2D arrays.

References

for time series. IEEE Transactions on Knowledge and Data Engineering, 25(6):1425–1438, 2013.

Examples

>>> import numpy as np
>>> from aeon.distances import msm_distance
>>> x = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]])
>>> y = np.array([[11, 12, 13, 14, 15, 16, 17, 18, 19, 20]])
>>> dist = msm_distance(x, y)