Time Series – Understanding Auto-Correlation vs Auto-Covariance

autocorrelationcorrelationcovariancecross correlationtime series

Autocorrelation is the cross-correlation of a signal with itself, and autocovariance is the cross-covariance of a signal with itself.

According to https://www.mathworks.com/help/signal/ug/correlation-and-covariance.html
the cross-correlation two wide-sense stationary random process, $x(n)$ and $y(n)$ is :

$R_{xy}(m) = E\{x(n+m)y(n) \}$

whereas the cross-covariance is defined as:

$C_{xy}(m) = E\{(x(n+m)-\mu_x) (y(n)-\mu_y) \} = R_{xy}(m) – \mu_x\mu_y$

However, statsmodels https://www.statsmodels.org/stable/_modules/statsmodels/tsa/stattools.html calls in its function for the autocorrelation (acf) the autocovariance function (acovf):

avf = acovf(x, unbiased=unbiased, demean=True, fft=fft, missing=missing)

where acovf subtracts the mean since demean is set to True.

xo = x - x.mean()

But according to the definition, the cross-correlation is simply the dot product without subtracting the mean.
What am I not getting here?

Best Answer

You're getting everything correct. There is unfortunately inconsistency over the terms auto-correlation and cross-correlation in time-series and signal processing literatures. The mathworks link you shared is a signal processing toolbox, and defines auto and cross correlations without demeaning and normalizing, just as in the wikipedia page. The Normalization section of the wikipedia page notes down this difference. In time-series courses/lectures you'll see the normalized version of auto-covariance as your auto-correlation function, which is the definition statsmodels uses.