# If a time-series has odd number of samples does it have no energy at Nyquist frequency?

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 ?

## 1 Answer

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

$$E_{Nyq}=\left|\sum_{n=0}^{N-1}x[n](-1)^n\right|^2\tag{1}$$

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

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