acf_se

mdtools.statistics.acf_se(x, axis=None, n=None)[source]

Calculate the standard errors of an autocorrelation function.

Parameters:
  • x (array_like) – The values of the ACF. Intermediate lag times must not be missing. That means if you used e.g. mdtools.statistics.acf() to compute the ACF, the argument dtau must have been 1.

  • axis (int or None, optional) – The axis along which to calculate the SE. By default, the flattened input array is used.

  • n (int, optional) – Sample size (i.e. number of recorded time points) of the underlying time series. By default, n is set to the number of lag times \(\tau\) in the given ACF. This is valid for ACFs that were computed at all possible lag times from the underlying time series. That means if you used e.g. mdtools.statistics.acf() to compute the ACF, the argument dtau must have been 1 and tau_max must have been None or the length of x along the given axis..

Returns:

se (numpy.ndarray) – Array of the same shape as x containing the standard error of the ACF at each lag time.

See also

mdtools.statistics.acf()

Calculate the autocorrelation function of an array

mdtools.statistics.acf_confint()

Calculate the confidence intervals of an autocorrelation function

Notes

The standard error (SE) of the autocorrelation function (ACF) \(C_\tau\) at lag time \(\tau\) is estimated according to Bartlett’s formula for MA(l) processes:[1],[2]

\[SE(C_\tau) = \sqrt{\frac{1 + 2 \sum_{\tau^{'} = 1}^{\tau - 1} C_{\tau^{'}}}{N}}\]

for \(\tau \gt 1\). For \(\tau = 1\) the standard error is estimated by \(SE(C_1) = \frac{1}{\sqrt{N}}\) and for \(\tau = 0\) the standard error is \(SE(C_0) = 0\).

References

Examples

>>> mdt.stats.acf_se([3])
array([0.])
>>> a = np.arange(4)
>>> mdt.stats.acf_se(a)
array([0.       , 0.5      , 0.8660254, 1.6583124])
>>> b = np.column_stack([a, a])
>>> mdt.stats.acf_se(b, axis=0)
array([[0.       , 0.       ],
       [0.5      , 0.5      ],
       [0.8660254, 0.8660254],
       [1.6583124, 1.6583124]])
>>> b = np.row_stack([a, a])
>>> mdt.stats.acf_se(b, axis=1)
array([[0.       , 0.5      , 0.8660254, 1.6583124],
       [0.       , 0.5      , 0.8660254, 1.6583124]])
>>> c = np.array([b, b])
>>> mdt.stats.acf_se(c, axis=2)
array([[[0.       , 0.5      , 0.8660254, 1.6583124],
        [0.       , 0.5      , 0.8660254, 1.6583124]],

       [[0.       , 0.5      , 0.8660254, 1.6583124],
        [0.       , 0.5      , 0.8660254, 1.6583124]]])