sbd_pairwise_distance#

sbd_pairwise_distance(x: ndarray, y: ndarray | None = None, standardize: bool = True) ndarray[source]#

Compute the shape-based distance (SBD) between all pairs of time series.

Parameters:
xnp.ndarray

A collection of time series instances of shape (n_instances, n_timepoints) or (n_instances, n_channels, n_timepoints).

ynp.ndarray or None, default=None

A single series or a collection of time series of shape (m_timepoints,) or (m_instances, m_timepoints) or (m_instances, m_channels, m_timepoints). If None, then the SBD is calculated between pairwise instances of x.

standardizebool, default=True

Apply z-score to both input time series for standardization before computing the distance. This makes SBD scaling invariant. Default is True.

Returns:
np.ndarray (n_instances, n_instances)

SBD matrix between the instances of x (and y).

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.

See also

sbd_distance

Compute the shape-based distance between two time series.

Examples

>>> import numpy as np
>>> from aeon.distances import sbd_pairwise_distance
>>> # Distance between each time series in a collection of time series
>>> X = np.array([[[1, 2, 3]],[[4, 5, 6]], [[7, 8, 9]]])
>>> sbd_pairwise_distance(X)
array([[0., 0., 0.],
       [0., 0., 0.],
       [0., 0., 0.]])
>>> # Distance between two collections of time series
>>> X = np.array([[[1, 2, 3]],[[4, 5, 6]], [[7, 8, 9]]])
>>> y = np.array([[[11, 12, 13]],[[14, 15, 16]], [[17, 18, 19]]])
>>> sbd_pairwise_distance(X, y)
array([[0., 0., 0.],
       [0., 0., 0.],
       [0., 0., 0.]])
>>> 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]])
>>> sbd_pairwise_distance(X, y_univariate)
array([[0.],
       [0.],
       [0.]])