Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a built in function to compute the autocorrelation of a signal ?

share|improve this question
You can get ListCorrelate to do this. – Szabolcs Feb 23 '12 at 14:17
up vote 9 down vote accepted

From the help file for ListConvolve, to find the autocorrelation of a list:

data = Table[Mod[i^2, 17], {i, 100}];
autocorrelation = ListConvolve[data, data, {1, 1}];
ListLinePlot[autocorrelation ]

Mathematica graphics

share|improve this answer
This only works because the list in the example is circularly even. (# == Reverse[#]) &@Rest@Table[Mod[i^2, 17], {i, 100}] gives True – Rojo Feb 23 '12 at 14:22

Yes, in version 9 you have CorrelationFunction built in.

data = Table[Mod[i^2, 17], {i, 100}];
autocorrelation = CorrelationFunction[data, {0, Length[data] - 1}];



share|improve this answer
@OleksandrR Thanks, I missed this in the documentation! (It's also ~100 faster :) – Ajasja Feb 21 '13 at 14:16
This does not seem to match the output of the ListConvolve method (just look at the y-scale). Using some test functions like a square pulse and a triangular pulse, I also don't get the expected output using CorrelationFunction. Any idea what the discrepancy is? I'm working with some applications of autocorrelation functions and I'm struggling to find the discrepancy between the two methods. – skratch Jun 4 '13 at 17:09
@skratch Nope. Look under the help to see exactly what is calculated using CorrelationFunction. – Ajasja Jun 4 '13 at 17:13
In response to myself and anyone else who may be interested: The "CorrelationFunction" approach seems to indeed be the "correct" one if you're looking for an autocorrelation function (ACF). I'm not so sure about ListConvolve and ListCorrelate... In v9, CorrelationFunction is scaled to vary between 1 and -1 and takes its maximum value at the first data point, which is a property of autocorrelation functions. – skratch Jun 5 '13 at 19:18

Perhaps this satisfies you?

autocorrelate[exp_, varFrom_, varTo_]:=Convolve[exp, exp/.varFrom->-varFrom, varFrom, varTo]

If your signal is discrete but symbolic, change Convolve to DiscreteConvolve. If they are lists, check out ListCorrelate

share|improve this answer

If you search the docs for "autocorrelation", ListConvolve turns up. There's also ListCorrelate. Does this work for you?

share|improve this answer
@Rojo the point I was sort of making is that typing "autocorrelate" in the help viewer takes you to ListConvolve which has an example. – acl Feb 23 '12 at 14:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.