distance¶
- distance(x: ndarray, y: ndarray, method: str | Callable[[ndarray, ndarray, Any], float], **kwargs: Unpack[DistanceKwargs]) float [source]¶
Compute the distance 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)
.- methodstr or Callable
The distance to use. A list of valid distance can be found in the documentation for
aeon.distances.get_distance_function
or by calling the functionaeon.distances.get_distance_function_names
.- kwargsAny
Arguments for distance. Refer to each distance documentation for a list of possible arguments.
- Returns:
- float
Distance between the x and y.
- Raises:
- ValueError
If x and y are not 1D, or 2D arrays. If distance is not a valid string or callable.
Examples
>>> import numpy as np >>> from aeon.distances import 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]]) >>> distance(x, y, method="dtw") 768.0