highest_autocorrelation

dtaianomaly.windowing.highest_autocorrelation(X: ndarray, lower_bound: int = 10, upper_bound: int = 1000)[source]

Compute the window size as the leg with the highest autocorrelation.

The autocorrelation of a time series equals the correlation of that time series with a lagged version of itself. It thus shows how similar the observations in the time series are to the observations a specific number of lags before. When the autocorrelation function is high, the time series is highly similar to the lagged version. Consequently, the window size can be computed as the number of lags for which the autocorrelation is maximized.

Parameters:
Xarray-like of shape (n_samples,)

Input time series.

lower_boundint, default=10

The lower bound on the automatically computed window size.

upper_boundint, default=1000

The lower bound on the automatically computed window size.

Returns:
int

The computed window size.

Warning

Automatically computing the windwow size only works for univariate time series!

Examples

>>> from dtaianomaly.data import demonstration_time_series
>>> from dtaianomaly.windowing import highest_autocorrelation
>>> X, _ = demonstration_time_series()
>>> highest_autocorrelation(X)
112