3
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ It refers to the properties of FFT for "even"/"odd" functions. $\endgroup$ – user18418 Nov 23 '15 at 19:30
  • $\begingroup$ Welcome to DSP.SE! Your answer really doesn't address this question, and nor does it add anything to the already-accepted answer. As a result, I've converted it to a comment. $\endgroup$ – Peter K. Nov 23 '15 at 20:53
5
$\begingroup$

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);
% zero pad
x = [x; zeros(n,1)];
% fft
fx = fft(x);
% mag sqaured
fa = fx.*conj(fx);
% inverse FFT
a = ifft(fa);
% plot
plot(-n+(1:2*n),circshift(a,-n));
answer = {'no','yes'};
fprintf('Is a Real?: %s \n',answer{isreal(a)+1});
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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