Calculating autocorrelation.