autocorrelation
autocorrelation(x, max_lag=None, type='correlation', confidence_level=0.95)Autocorrelation, autocovariance, or partial autocorrelation function.
Mirrors the C# Autocorrelation class. Computes the requested function out to max_lag (default floor(min(10*log10(N), N-1)), matching the C# default) and attaches the asymptotic confidence band for ACF/PACF rho values at confidence_level.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| x | array_like | At least two elements. | required |
| max_lag | int | Maximum lag. None (the default) uses the C# default rule. |
None |
| type | ('correlation', 'covariance', 'partial') | "correlation" |
|
| confidence_level | float | 0.95 |
Returns
| Name | Type | Description |
|---|---|---|
| dict | Keys lag, value (both :class:numpy.ndarray), type, and ci (a dict with lower/upper). |
Examples
>>> from corehydropy import autocorrelation
>>> x = [5, 6, 4, 7, 3, 8, 2, 9, 1, 10, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10]
>>> round(float(autocorrelation(x, max_lag=5)["value"][0]), 12)
1.0