# Finding Peaks in an Autocorrelation Function

I'm trying to find the period of a signal. I've used FFT to compute the autocorrelation of the signal. As can be seen from the autocorrelation function (plotted below) I obtained, there are 70 sample between peaks which actually indicates the period of my signal.

What is the best way to extract the indices of these peaks from such a data?

## 1 Answer

Removing the DC offset from your signal will get rid of the triangular "trend" seen here. Another way to detrend data (which is not specific to autocorrelation functions) is to subtract from your function a median-filtered version of itself (the median-filtered version corresponding to the trend).

You can then detect peak by detecting local maxima - if $X(n) = \max_{k \in [k-W, k+W]} X(k)$, then $n$ is a peak. $W$ is a scale factor which indicates how narrow and close to each other you allow your peaks to be.

• I don't believe the triangular shape is due to use of the unbiased vs biased estimator. Even if the unbiased estimator were to be used, you'd still get a "constant" offset. That's because the data seems to have a DC offset. Remove that before any further processing. – Peter K. Sep 10 '12 at 23:30
• You are correct indeed, it looks like the input signal has a DC offset; and I have edited my answer accordingly. – pichenettes Sep 11 '12 at 1:35
• Debiasing is still useful when it is required to assess the relative strength of peaks. – pichenettes Sep 11 '12 at 1:44
• Certainly, the unbiased estimator should be used, I just think that's a second order effect compared with removing the DC component. – Peter K. Sep 11 '12 at 12:22