autocorr¶
- autocorr(dt, z, axis=0, **kwargs)[source]¶
Return the autocorrelation spectrum at a single lag or successive lags. Default behavior returns the lag-0 autocorrelation.
- Parameters
dt (float or array-like, optional) – The timestep or time series (from which the timestep is inferred).
z (array-like) – The input data.
axis (int, optional) – Axis along which autocorrelation is taken.
lag (float, optional) – Return autocorrelation for the single lag
lag
(must be divisible bydt
).ilag (int, optional) – As with
lag
but specifies the index instead of the physical time.maxlag (float, optional) – Return lagged autocorrelation up to the lag
maxlag
(must be divisible bydt
).imaxlag (int, optional) – As with
maxlag
but specifies the index instead of the physical time.
- Returns
lags (array-like) – The lags.
result (array-like) – The autocorrelation as a function of lag.
Notes
This function uses the following formula to estimate autocorrelation at lag \(k\):
\[\dfrac{% \sum_{i=0}^{n-k} \left(x_t - \overline{x}\right) \left(y_{t+k} - \overline{y}\right) }{% (n - k) s_x s_y }\]where \(\overline{x}\) and \(\overline{y}\) are the sample means and \(s_x\) and \(s_y\) are the sample standard deviations.