# cross-correlation with time lag

I have two lists with some data.

a={1,2,3,4,5}
b={5,4,3,2,1}

Now I want to compute the cross correlation of the two lists with a time lag of 1, like it is mentioned on wikipedia: https://en.wikipedia.org/wiki/Cross-correlation

The only function I found in mathematica is CorrelationFunction, but this one seems to only compute the autocorrelation of a lists with itself. So I was wondering if there is another function or how do do this. Can anybody help me out?

-

You can do the cross-correlation between two sequences using ListCorrelate

a = {1, 2, 3, 4, 5};
b = {5, 4, 3, 2, 1};
ListCorrelate[a, b, 1]

This does circular correlation, so you may want to look at the options to get the exact calculation you are looking for.

-

Try this:

a.RotateLeft[b, 1]
(*45*)

For any other time delay $k$, use a.RotateLeft[b, k] instead.

If the lists are extremely long and you are trying to compute the cross-correlation with a variety of delays, you can look into an FFT-based convolutive method.

-