wdtw_distance#

wdtw_distance(x: ndarray, y: ndarray, window: float = None, g: float = 0.05) float[source]#

Compute the wdtw distance between two time series.

First proposed in [1], WDTW adds a adds a multiplicative weight penalty based on the warping distance. This means that time series with lower phase difference have a smaller weight imposed (i.e less penalty imposed) and time series with larger phase difference have a larger weight imposed (i.e. larger penalty imposed).

Formally this can be described as:

\[d_{w}(x_{i}, y_{j}) = ||w_{|i-j|}(x_{i} - y_{j})||\]

Where d_w is the distance with a the weight applied to it for points i, j, where w(|i-j|) is a positive weight between the two points x_i and y_j.

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, defaults=None

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

g: float, defaults=0.05

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

Returns:
float

wdtw distance between x and y.

Raises:
ValueError

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

References

[1]

Young-Seon Jeong, Myong K. Jeong, Olufemi A. Omitaomu, Weighted dynamic time

warping for time series classification, Pattern Recognition, Volume 44, Issue 9, 2011, Pages 2231-2240, ISSN 0031-3203, https://doi.org/10.1016/j.patcog.2010.09.022.

Examples

>>> import numpy as np
>>> from aeon.distances import wdtw_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 = wdtw_distance(x, y)