erp_distance#

erp_distance(x: ndarray, y: ndarray, window: float = None, g: float = 0.0, g_arr: ndarray = None) float[source]#

Compute the ERP distance between two time series.

ERP, first proposed in [1], attempts to align time series by better considering how indexes are carried forward through the cost matrix. Usually in the dtw cost matrix, if an alignment can’t be found the previous value is carried forward. Erp instead proposes the idea of gaps or sequences of points that have no matches. These gaps are then punished based on their distance from ‘g’.

The optimal value of g is selected from the range [σ/5, σ], where σ is the standard deviation of the training data. When there is > 1 channel, g should be a np.ndarray where the nth value is the standard deviation of the nth channel.

Parameters:
x: np.ndarray, of shape (n_channels, n_timepoints) or (n_timepoints,)

First time series.

y: np.ndarray, of shape (m_channels, m_timepoints) or (m_timepoints,)

Second time series.

window: float, defaults=None

The window to use for the bounding matrix. If None, no bounding matrix is used.

g: float.

The reference value to penalise gaps. The default is 0.

g_arr: np.ndarray of shape (n_channels), defaults=None

Numpy array that must be the length of the number of channels in x and y.

Returns:
float

ERP distance between x and y.

Raises:
ValueError

If x and y are not 1D or 2D arrays.

References

[1]

Lei Chen and Raymond Ng. 2004. On the marriage of Lp-norms and edit distance.

In Proceedings of the Thirtieth international conference on Very large data bases
  • Volume 30 (VLDB ‘04). VLDB Endowment, 792–803.

Examples

>>> import numpy as np
>>> from aeon.distances import erp_distance
>>> x = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]])
>>> y = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]])
>>> dist = erp_distance(x, y)