Computing the autocorrelation of a time series