ddtw_distance¶
- ddtw_distance(x: ndarray, y: ndarray, window: float | None = None, itakura_max_slope: float | None = None) float[source]¶
Compute the DDTW distance between two time series.
Derivative dynamic time warping (DDTW) is an adaptation of DTW originally proposed in [1]. DDTW takes a version of the first derivatives of the series prior to performing standard DTW. The derivative function, defined in [1], is:
\[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.
- 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.
- 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:
- float
ddtw distance between x and y.
- Raises:
- ValueError
If x and y are not 1D or 2D arrays. If n_timepoints or m_timepoints are less than 2.
References
Examples
>>> import numpy as np >>> from aeon.distances import ddtw_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(ddtw_distance(x, y)) 2180