manhattan_distance

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

Compute the manhattan distance between two time series.

The manhattan distance between two time series is defined as:

\[manhattan(x, y) = \sum_{i=1}^{n} |x_i - y_i|\]
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

manhattan 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 manhattan_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]])
>>> manhattan_distance(x, y)
100.0