autocorr

autocorr(dt, z, axis=0, **kwargs)[source]

Return the autocorrelation spectrum at successive lags.

Parameters
  • dt (float or array-like) – The timestep or regularly-spaced time coordinates.

  • z (array-like) – The input data.

  • axis (int, optional) – Axis along which autocorrelation is taken.

  • lag (int, optional) – Return autocorrelation at the single lag lag.

  • nlag (int, optional) – Return lagged autocorrelation from 0 timesteps up to nlag timesteps.

Returns

  • lags (array-like) – The lags.

  • result (array-like) – The autocorrelation as a function of lag.

Note

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.