wdtw_cost_matrix

wdtw_cost_matrix(x: ndarray, y: ndarray, window: float | None = None, g: float = 0.05, itakura_max_slope: float | None = None) ndarray[source]

Compute the WDTW 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.

gfloat, default=0.05

Constant that controls the level of penalisation for the points with larger phase difference. Default is 0.05.

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.

Returns:
np.ndarray (n_timepoints_x, n_timepoints_y)

WDTW 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 wdtw_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]])
>>> wdtw_cost_matrix(x, y)
array([[  0.        ,   0.450166  ,   2.30044662,   6.57563393,
         14.37567559,  26.87567559,  45.32558186,  71.04956205,
        105.44507215, 149.98162593],
       [  0.450166  ,   0.        ,   0.450166  ,   2.30044662,
          6.57563393,  14.37567559,  26.87567559,  45.32558186,
         71.04956205, 105.44507215],
       [  2.30044662,   0.450166  ,   0.        ,   0.450166  ,
          2.30044662,   6.57563393,  14.37567559,  26.87567559,
         45.32558186,  71.04956205],
       [  6.57563393,   2.30044662,   0.450166  ,   0.        ,
          0.450166  ,   2.30044662,   6.57563393,  14.37567559,
         26.87567559,  45.32558186],
       [ 14.37567559,   6.57563393,   2.30044662,   0.450166  ,
          0.        ,   0.450166  ,   2.30044662,   6.57563393,
         14.37567559,  26.87567559],
       [ 26.87567559,  14.37567559,   6.57563393,   2.30044662,
          0.450166  ,   0.        ,   0.450166  ,   2.30044662,
          6.57563393,  14.37567559],
       [ 45.32558186,  26.87567559,  14.37567559,   6.57563393,
          2.30044662,   0.450166  ,   0.        ,   0.450166  ,
          2.30044662,   6.57563393],
       [ 71.04956205,  45.32558186,  26.87567559,  14.37567559,
          6.57563393,   2.30044662,   0.450166  ,   0.        ,
          0.450166  ,   2.30044662],
       [105.44507215,  71.04956205,  45.32558186,  26.87567559,
         14.37567559,   6.57563393,   2.30044662,   0.450166  ,
          0.        ,   0.450166  ],
       [149.98162593, 105.44507215,  71.04956205,  45.32558186,
         26.87567559,  14.37567559,   6.57563393,   2.30044662,
          0.450166  ,   0.        ]])