squared_distance(x: ndarray, y: ndarray, **kwargs: Any) 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\]
x: np.ndarray (1d or 2d array)

First time series.

y: np.ndarray (1d or 2d array)

Second time series.

kwargs: Any

Extra kwargs. For squared there are none however, this is kept for consistency.


Squared distance between x and y.


If the value of x or y provided is not a numpy array. If the value of x or y has more than 2 dimensions. If a metric string provided, and is not a defined valid string. If a metric object (instance of class) is provided and doesn’t inherit from NumbaDistance. If a resolved metric is not no_python compiled. If the metric type cannot be determined.


>>> import numpy as np
>>> from sktime.distances import squared_distance
>>> x_1d = np.array([1, 2, 3, 4])  # 1d array
>>> y_1d = np.array([5, 6, 7, 8])  # 1d array
>>> squared_distance(x_1d, y_1d)
>>> x_2d = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])  # 2d array
>>> y_2d = np.array([[9, 10, 11, 12], [13, 14, 15, 16]])  # 2d array
>>> squared_distance(x_2d, y_2d)