Suppose I have real time series A with n samples and time-spacing dt and I want to analyze its frequency content.

Af = fft(A)

If dt=1 Nyquist frequency is 0.5. According to both Numpy and Matlab manuals, the frequency vector is defined as

f = [0, 1, ...,   n/2-1,     -n/2, ..., -1] / (dt*n)   if n is even

f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (dt*n)   if n is odd

If n=9 (odd), f= [-0.44444 -0.33333 -0.22222 -0.11111  0.  0.11111 0.22222  0.33333  0.44444]
If n=8 (even), f= [-0.5   -0.375 -0.25  -0.125  0.     0.125  0.25   0.375]

Note the maximum frequency for odd number of samples is 0.44444 Hz not 0.5 Hz. Does this mean a time series with odd number of samples has no energy at Nyquist frequency ?


No, that's not what it means. You just don't get a frequency bin at Nyquist if the DFT length is odd. If you want you can always append one or more zeros to the time domain sequence such that the total length becomes even.

If you're just interested in the energy at Nyquist, you could also simply compute


where $N$ is the length of the sequence, no matter if it's even or odd.

  • $\begingroup$ What if the signal is periodic? $\endgroup$ – Dan Szabo Dec 15 '20 at 13:48

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.