adtw_cost_matrix

adtw_cost_matrix(x: ndarray, y: ndarray, window: float | None = None, itakura_max_slope: float | None = None, warp_penalty: float = 1.0) ndarray[source]

Compute the ADTW cost matrix between two time series.

Parameters:
xnp.ndarray

First time series, either univariate, shape (n_timepoints,), or multivariate, shape (n_channels, n_timepoints).

ynp.ndarray

Second time series, either univariate, shape (n_timepoints,), or multivariate, shape (n_channels, n_timepoints).

windowfloat, default=None

The window to use for the bounding matrix. If None, no bounding matrix is used. window is a percentage deviation, so if window = 0.1, 10% of the series length is the max warping allowed. is used.

itakura_max_slopefloat, default=None

Maximum slope as a proportion of the number of time points used to create Itakura parallelogram on the bounding matrix. Must be between 0. and 1.

warp_penalty: float, default=1.0

Penalty for warping. A high value will mean less warping.

Returns:
np.ndarray (n_timepoints, m_timepoints)

adtw 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 adtw_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]])
>>> adtw_cost_matrix(x, y)
array([[  0.,   2.,   7.,  17.,  34.,  60.,  97., 147., 212., 294.],
       [  2.,   0.,   2.,   7.,  17.,  34.,  60.,  97., 147., 212.],
       [  7.,   2.,   0.,   2.,   7.,  17.,  34.,  60.,  97., 147.],
       [ 17.,   7.,   2.,   0.,   2.,   7.,  17.,  34.,  60.,  97.],
       [ 34.,  17.,   7.,   2.,   0.,   2.,   7.,  17.,  34.,  60.],
       [ 60.,  34.,  17.,   7.,   2.,   0.,   2.,   7.,  17.,  34.],
       [ 97.,  60.,  34.,  17.,   7.,   2.,   0.,   2.,   7.,  17.],
       [147.,  97.,  60.,  34.,  17.,   7.,   2.,   0.,   2.,   7.],
       [212., 147.,  97.,  60.,  34.,  17.,   7.,   2.,   0.,   2.],
       [294., 212., 147.,  97.,  60.,  34.,  17.,   7.,   2.,   0.]])