erp_cost_matrix¶
- erp_cost_matrix(x: ndarray, y: ndarray, window: float | None = None, g: float = 0.0, g_arr: ndarray | None = None, itakura_max_slope: float | None = None) ndarray [source]¶
Compute the ERP cost matrix between two 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)
.- windowfloat, default=None
The window to use for the bounding matrix. If None, no bounding matrix is used.
- gfloat, defualt=0.0
The reference value to penalise gaps. The default is 0.
- g_arrnp.ndarray, of shape (n_channels), default=None
Numpy array that must be the length of the number of channels in x and y.
- itakura_max_slopefloat, default=None
Maximum slope as a proportion of the number of time points used to create Itakura parallelogram on the bounding matrix. Must be between 0. and 1.
- Returns:
- np.ndarray (n_timepoints_x, n_timepoints_y)
ERP cost matrix 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 erp_cost_matrix >>> 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]]) >>> erp_cost_matrix(x, y) array([[ 0., 2., 5., 9., 14., 20., 27., 35., 44., 54.], [ 2., 0., 3., 7., 12., 18., 25., 33., 42., 52.], [ 5., 3., 0., 4., 9., 15., 22., 30., 39., 49.], [ 9., 7., 4., 0., 5., 11., 18., 26., 35., 45.], [14., 12., 9., 5., 0., 6., 13., 21., 30., 40.], [20., 18., 15., 11., 6., 0., 7., 15., 24., 34.], [27., 25., 22., 18., 13., 7., 0., 8., 17., 27.], [35., 33., 30., 26., 21., 15., 8., 0., 9., 19.], [44., 42., 39., 35., 30., 24., 17., 9., 0., 10.], [54., 52., 49., 45., 40., 34., 27., 19., 10., 0.]])