The Finite Observation Window
In practice, we never observe an infinite signal. We record exactly N samples and then stop. Mathematically, this is equivalent to multiplying the infinite signal x[n] by a rectangular window wrect[n] that is 1 for n = 0, 1, …, N−1 and 0 everywhere else. The DFT then analyses this windowed signal xw[n] = x[n] · wrect[n], not the original x[n].
Because multiplication in time corresponds to convolution in frequency, the DFT of xw[n] is the convolution of the true spectrum X(ejω) with the spectrum of the window W(ejω). For the rectangular window, Wrect(ejω) has a large main lobe and many sidelobes — this is the root cause of spectral leakage.
Spectral Leakage
Spectral leakage occurs when energy from a sinusoid at one frequency "leaks" into neighboring DFT bins. This happens whenever the sinusoid's frequency does not fall exactly on a DFT bin. The frequency response of the rectangular window is a Dirichlet kernel — a sinc-like function with sidelobes that decay slowly at −13 dB below the main lobe peak:
Coherent sampling means the signal frequency is an exact integer multiple of the frequency resolution Δf = fs/N. In this case, the sinusoid completes a whole number of cycles within the N-sample window, so the rectangular window introduces no leakage — all energy concentrates in a single DFT bin.
No leakage when fsignal = k · fs / N for some integer kWindow Functions
Window functions are alternative tapering shapes applied to x[n] before computing the DFT. Unlike the abrupt cut-off of the rectangular window, well-designed windows taper smoothly to zero at both ends. This smoothness trades a wider main lobe (lower frequency resolution) for much lower sidelobes (reduced leakage). Every window represents a point on this resolution–leakage trade-off curve.
The Resolution–Leakage Trade-off
There is a fundamental tension in spectral analysis: frequency resolution (the ability to distinguish two nearby tones) and leakage suppression (the ability to detect a weak tone near a strong one) cannot both be maximized simultaneously. Every window function occupies a point on this trade-off:
Better sidelobe suppression → lower leakage but wider main lobe → harder to separate two nearby tones.
Narrower main lobe → finer resolution but higher sidelobes → weak nearby tones may be masked by leakage from strong ones.
The Kaiser window (parameterized by β) lets you tune this trade-off continuously: higher β increases sidelobe suppression at the cost of a wider main lobe.
The true frequency resolution — the minimum separation Δf between two sinusoids that can be distinguished — depends on both the window shape and the number of samples N. For the rectangular window, two tones can be resolved if their separation exceeds one bin (Δf = fs/N). For a Hann window, the effective resolution is approximately 2·Δf because the main lobe is twice as wide.
Practical Strategies
When performing spectral analysis in practice, the choice of window and DFT length should be guided by the specific requirements of your application:
- Every DFT analysis implicitly multiplies the signal by a window function — the rectangular window by default. This truncation causes spectral leakage.
- Leakage arises because multiplication in time corresponds to convolution in frequency with the window's spectrum (Dirichlet kernel for the rectangular window).
- Coherent sampling (signal frequency = integer multiple of Δf) eliminates leakage entirely; otherwise, energy spreads into adjacent bins.
- Window functions (Hann, Hamming, Blackman, Kaiser) trade wider main lobes for lower sidelobes, reducing leakage at the cost of frequency resolution.
- The effective resolution with a non-rectangular window is α·Δf where α ≥ 1 is the window's broadening factor (≈2 for Hann, ≈3 for Blackman).
- To improve true frequency resolution, collect more samples; zero-padding only smooths the spectral plot.
- Apply a window gain correction factor after windowing to keep amplitude measurements accurate.