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

Compute the WDDTW distance between two time series.

Weighted derivative dynamic time warping (WDDTW) Takes the first order derivative, then applies _weighted_cost_matrix to find WDTW distance. WDDTW was first proposed in [1] as an extension of DDTW. By adding a weight to the derivative it means the alignment isn’t only considering the shape of the time series, but also the phase.

Formally the derivative is calculated as:

\[d_{i}(x) = \frac{{}(x_{i} - x_{i-1} + ((x_{i+1} - x_{i-1}/2)}{2}\]

where \(x\) is the original time series and \(d_x\) is the derived time series.


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


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.


WDDTW distance between x and y.


If x and y are not 1D or 2D arrays. If n_timepoints or m_timepoints are less than 2.



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.


>>> import numpy as np
>>> from aeon.distances import wddtw_distance
>>> x = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]])
>>> y = np.array([[42, 23, 21, 55, 1, 19, 33, 34, 29, 19]])
>>> round(wddtw_distance(x, y))