squared_pairwise_distance#

squared_pairwise_distance(X: ndarray, y: ndarray = None) ndarray[source]#

Compute the squared pairwise distance between a set of 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). If None, then the squared pairwise distance between the instances of X is calculated.

Returns:
np.ndarray (n_instances, n_instances)

squared pairwise matrix between the instances of X.

Raises:
ValueError

If X is not 2D or 3D array when only passing X. If X and y are not 1D, 2D or 3D arrays when passing both X and y.

Examples

>>> import numpy as np
>>> from aeon.distances import squared_pairwise_distance
>>> X = np.array([[[1, 2, 3, 4]],[[4, 5, 6, 3]], [[7, 8, 9, 3]]])
>>> squared_pairwise_distance(X)
array([[  0.,  28., 109.],
       [ 28.,   0.,  27.],
       [109.,  27.,   0.]])
>>> X = np.array([[[1, 2, 3]],[[4, 5, 6]], [[7, 8, 9]]])
>>> y = np.array([[[11, 12, 13]],[[14, 15, 16]], [[17, 18, 19]]])
>>> squared_pairwise_distance(X, y)
array([[300., 507., 768.],
       [147., 300., 507.],
       [ 48., 147., 300.]])
>>> X = np.array([[[1, 2, 3]],[[4, 5, 6]], [[7, 8, 9]]])
>>> y_univariate = np.array([[11, 12, 13],[14, 15, 16], [17, 18, 19]])
>>> squared_pairwise_distance(X, y_univariate)
array([[300.],
       [147.],
       [ 48.]])