0
$\begingroup$

I'm attempting to understand spectral leakage and read the following quote on wikipedia:

Windowing a sinusoid causes spectral leakage, even if the sinusoid has an integer number of cycles within a rectangular window.

This confuses me, since I thought using an integral number of periods caused the leakage to disappear. Moreover, my attempts to quantify/simulate this corroborate my beliefs. For example, take the following sampled, 1Hz simple sinusoid.

import numpy as np

f = 1
ts = f / 3
fs = 1 / ts
t = np.arange(0, 5.1 * f, step=ts)
s = np.sin(2*np.pi*f*t)

enter image description here

with fft:

fft = np.absolute(np.fft.rfft(s))
fft /= np.sum(fft)
bins = np.fft.rfftfreq(len(t))

enter image description here

Now if I add an additional sample,

import numpy as np

f = 1
ts = f / 3
fs = 1 / ts
t = np.arange(0, 5.1 * f, step=ts)
s = np.sin(2*np.pi*f*t)

enter image description here

As expected, I get spectral leakage.

enter image description here

Is the Wikipedia quote incorrect, or did I misinterpret it?

Note: I think a better tag for this is spectral-leakage, but I don't have enough reputation to add it.

$\endgroup$
  • 1
    $\begingroup$ The article seems to refer to a rectangular window that's shorter than the actual FFT length. $\endgroup$ – Hilmar Jan 23 at 20:26
  • $\begingroup$ Where does it say that? I missed that part when I read it. $\endgroup$ – MattHusz Jan 23 at 22:03
  • $\begingroup$ If you look at the image above it shows it $\endgroup$ – DamienBradley Jan 24 at 0:13
0
$\begingroup$

If you have an integer number of cycles (exactly) within a DFT frame, and the signal is not windowed (aside from the rectangular window extending to the edges of the DFT fram that would result), there is no spectral leakage. What the article is referring to I believe is more commonly called zero padding which would then cause the DFT to approach the DTFT, interpolating frequency samples between the bins. I personally wouldn't call this spectral leakage although you could mathematically get to the same conclusion in that energy in a DFT bin simply represents correlation to the input signal. If energy is there, and the bin isn't your true frequency, then sure, it is "spectral leakage". In that paradigm however of zero-padding, I prefer to associate it with the concept of frequency interpolation (again the math and the results are the same, so no disagreement - just convention).

Spectral leakage occurs when you have a non-integer number of cycles such that your true frequency is mid way between DFT bins. Each DFT bin actually has a very wide frequency response with nulls at every other bin. So a frequency that is in between bins will show up within the response of the other bins, while a frequency that is exactly on bin center (integer number of cycles) will be in the null of the responses of the other bins. There is therefore no leakage under this condition (that is not an illusion as the article suggests- there is simply no leakage - but I do see how the author presented both options and stated "depending on your point of view"). And for the other conditions the signal "leaks" into the response of the other bins.

I explain this further here at this post.

Intuition for sidelobes in FFT

$\endgroup$
0
$\begingroup$

When there is an exact integer number of cycles of a periodic signal in the FFT aperture, there is no spectral leakage.

I said this before but the DFT maps a periodic sequence of length $N$ to another periodic sequence of length $N$ and the iDFT maps it back. That is fundamentally what the Discrete Fourier Transform does.

More elaboration here and here.

$\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.