Explaining spectral leakage and window effects
Spectral leakage occurs because the DFT assumes the finite signal is periodically extended, so if the signal’s frequency doesn’t match an integer DFT bin, the periodic extension creates discontinuities at the edges. This causes the Fourier transform of the finite windowed signal to be a convolution of the ideal spectrum with the window’s spectrum, spreading energy across bins. Rectangular windows produce sinc-shaped spectra with high side lobes causing significant leakage, while smoother windows like Hamming taper the edges, reducing side lobe levels and thus leakage, at the cost of wider main lobes and reduced frequency resolution.
The (N)–point DFT does not give you “the” spectrum of an arbitrary finite record, it gives you the values of the discrete–time Fourier transform of whatever signal you present to it, sampled on the grid (k\frac{F_s}{N}). Two points follow from that:
-
The DFT basis functions are exactly (N)‑point sinusoids at those grid frequencies. Only if your signal contains an exact integer number of cycles in the (N) samples does it project entirely into one basis function. If the signal’s frequency falls between bins, its inner product with every basis function is non–zero and you will see non‑zero coefficients in many bins.
-
Forming a finite record is equivalent to multiplying an infinite signal by a window (w[n]) of length (N). Multiplication in the time domain is convolution in the frequency domain. The spectrum of a single tone is a pair of impulses at (\pm f_0); convolving those impulses with the spectrum of the window smears them out into a “main lobe” at (f_0) with sidelobes to either side. Sampling that continuous spectrum at the DFT bin frequencies is what you perceive as “leakage” into adjacent bins.
For the rectangular window, (w[n]=1) for (0\leq n<N), the frequency response is a sinc function: a narrow main lobe and sidelobes only 13 dB down that decay slowly as (1/f). Convolving your tone with that sinc produces significant energy far from the true tone frequency, hence the high leakage.
Tapered windows such as the Hamming,
[
w[n]=0.54-0.46\cos\frac{2\pi n}{N-1},
]
remove the discontinuity at the record boundaries. That makes (w[n]) and its first derivative continuous, which reduces the high–frequency content of (W(f)). In the frequency domain the main lobe is wider, but the sidelobes are much lower (≈ –40 dB for a Hamming) and decay faster. When you convolve a tone with this (W(f)), much less energy is spread into distant bins, so the leakage into adjacent bins is reduced at the expense of frequency resolution.