euclidean_distance

euclidean_distance(x: ndarray, y: ndarray) float[source]

Compute the Euclidean distance between two time series.

The Euclidean distance between two time series of length m is the square root of the squared distance and is defined as:

\[ed(x, y) = \sqrt{\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

Euclidean 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 euclidean_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]])
>>> euclidean_distance(x, y)
31.622776601683793