distance

distance(x: ndarray, y: ndarray, metric: str | Callable[[ndarray, ndarray, Any], float], **kwargs: Unpack) 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).

metricstr or Callable

The distance metric to use. A list of valid distance metrics can be found in the documentation for aeon.distances.get_distance_function or by calling the function aeon.distances.get_distance_function_names.

kwargsAny

Arguments for metric. Refer to each metrics 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 metric 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, metric="dtw")
768.0