squared_distance¶
- squared_distance(x: ndarray, y: ndarray) float [source]¶
Compute the squared distance between two time series.
The squared distance between two time series is defined as:
\[sd(x, y) = \sum_{i=1}^{n} (x_i - y_i)^2\]- 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)
.
- Returns:
- float
Squared distance 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 squared_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]]) >>> squared_distance(x, y) 1000.0