Computing an autocorrelation
In many cases, events occur in a repeating cycle. If the data correlates with itself, this is called an autocorrelation. With some data, the interval may be obvious because there's some visible external influence, such as seasons or tides. With some data, the interval may be difficult to discern.
In the Computing the coefficient of a correlation recipe, we looked at a way to measure correlation between two sets of data.
If we suspect we have cyclic data, can we leverage the previous correlation function to compute an autocorrelation?
Getting ready
The core concept behind autocorrelation is the idea of a correlation through a shift in time, T. The measurement for this is sometimes expressed as rxx(T): the correlation between x and x with a time shift of T.
Assume we have a handy correlation function, R(x, y). It compares two sequences, [x0, x1, x2, ...] and [y0, y1, y2, ...], and returns the coefficient of correlation between the two sequences:
rxy = R([x0, x1, x2,...