Tell me more ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

share|improve this question
1  
You can get ListCorrelate to do this. – Szabolcs Feb 23 '12 at 14:17

4 Answers

up vote 7 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
1  
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}];

ListLinePlot[autocorrelation]

autocorrelation

share|improve this answer
@OleksandrR Thanks, I missed this in the documentation! (It's also ~100 faster :) – Ajasja Feb 21 at 14:16

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
1  
@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

 
discard

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.