def autocov(x, lag=1):
"""Return the autocovariance.
Assumes a (weak) univariate stationary process with mean 0.
Realizations are in rows.
Parameters
----------
x : np.array of size (n, m)
lag : int, optional
Returns
-------
C : np.array of size (n,)
"""
x = np.atleast_2d(x)
# In R this is normalized with x.shape[1]
C = np.mean(x[:, lag:] * x[:, :-lag], axis=1)
return C
评论列表
文章目录