msm_cost_matrix#

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

Compute the MSM cost matrix between two time series.

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: int or None

The window size to use for the bounding matrix. If None, the bounding matrix is not 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:
np.ndarray (n_timepoints_x, n_timepoints_y)

MSM cost matrix between x and y.

Raises:
ValueError

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

Examples

>>> import numpy as np
>>> from aeon.distances import msm_cost_matrix
>>> x = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]])
>>> y = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]])
>>> msm_cost_matrix(x, y)
array([[ 0.,  2.,  4.,  6.,  8., 10., 12., 14., 16., 18.],
       [ 2.,  0.,  2.,  4.,  6.,  8., 10., 12., 14., 16.],
       [ 4.,  2.,  0.,  2.,  4.,  6.,  8., 10., 12., 14.],
       [ 6.,  4.,  2.,  0.,  2.,  4.,  6.,  8., 10., 12.],
       [ 8.,  6.,  4.,  2.,  0.,  2.,  4.,  6.,  8., 10.],
       [10.,  8.,  6.,  4.,  2.,  0.,  2.,  4.,  6.,  8.],
       [12., 10.,  8.,  6.,  4.,  2.,  0.,  2.,  4.,  6.],
       [14., 12., 10.,  8.,  6.,  4.,  2.,  0.,  2.,  4.],
       [16., 14., 12., 10.,  8.,  6.,  4.,  2.,  0.,  2.],
       [18., 16., 14., 12., 10.,  8.,  6.,  4.,  2.,  0.]])