# AutoCorrelation using FFT of power spectrum

I have a chunk of data (samples) that need to do autocorrelation using FFT method. All data are real and lies between -1 and +1. What I have done follows:

1. Zero pad the window with the length equals the samples' length.
2. FFT of result from 1
3. Result from 2 has Real and Imaginary parts. I used them to find Power Spectral Density by taking Re*Re + Im*Im.
4. Take the inverse Fast Fourier Transform.

Now here is my question: The result from part 4 contains Real and Imaginary parts. Is the magnitude of it equals the autocorrelation result? If so, since my input contains positive and negative values, the magnitude of Result from part 4 means the autocorrelation result cannot be negative, which doesn't make sense.

Or should I take only the Real part of result from Part 4 as the autocorrelation result? My input is real and so the autocorrelation shouldn't have any imaginary part, right?

• It refers to the properties of FFT for "even"/"odd" functions.
– user18418
Nov 23, 2015 at 19:30
– Peter K.
Nov 23, 2015 at 20:53

In principle you are doing the right thing. Step 4 should produce a real result unless there is a coding error. Sometimes you add up some residual imaginary part due to numerical noise but, if any, that should be very small.

Here is an example

%% random signal of length n
n = 128;
x = rand(n,1);