Reading
Stories Mode

Frequency Resolution and Windowing

~15 min read Lesson 3 of Module 5

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].

Windowed Signal
x_w[n] = x[n] \cdot w[n] \quad \Longleftrightarrow \quad X_w(e^{j\omega}) = \frac{1}{2\pi}\int_{-\pi}^{\pi} X(e^{j\theta})\,W(e^{j(\omega-\theta)})\,d\theta
Multiplying by a window w[n] in time corresponds to convolving with the window's frequency response W(ejω) in the frequency domain. Even a perfectly clean sinusoid gets smeared across many frequency bins as a result.

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:

Rectangular Window DTFT (Dirichlet Kernel)
W_{\mathrm{rect}}(e^{j\omega}) = e^{-j\omega(N-1)/2}\,\frac{\sin(\omega N/2)}{\sin(\omega/2)}
The magnitude |Wrect(ejω)| has a main lobe of width 4π/N (in rad/sample) and sidelobes at −13 dB. The slow sidelobe rolloff is why the rectangular window causes severe leakage.
Coherent Sampling — When There Is No Leakage

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 k

Window 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.

Rectangular
Narrowest Main Lobe
Best frequency resolution but highest sidelobes (−13 dB). Use only when signals are well separated and leakage is not a concern.
Hann
General Purpose
Sidelobes at −31 dB, main lobe 2× wider than rectangular. The most common choice for general spectral analysis — good balance.
Hamming
First-Sidelobe Optimized
First sidelobe suppressed to −43 dB (slightly better than Hann), though far sidelobes are slightly higher. Similar main lobe width to Hann.
Blackman
Lowest Sidelobes
Sidelobes at −58 dB but main lobe is 3× wider than rectangular. Use when dynamic range is critical and resolution can be sacrificed.
Hann Window
w_{\mathrm{Hann}}[n] = 0.5\left(1 - \cos\!\left(\frac{2\pi n}{N-1}\right)\right), \quad 0 \le n \le N-1
The Hann window is a raised-cosine taper. It smoothly reaches zero at both ends, eliminating the discontinuity that causes the severe sidelobes of the rectangular window. The cosine term redistributes energy toward the center of the window.

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:

Trade-off Summary

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.

Effective Frequency Resolution
\Delta f_{\mathrm{eff}} = \alpha \cdot \frac{f_s}{N}
The window factor α depends on the window type: α ≈ 1 for rectangular, α ≈ 2 for Hann/Hamming, α ≈ 3 for Blackman. To improve resolution with a fixed window, you must collect more data (increase N or equivalently record longer).

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:

Step 1
Collect More Data
The only way to genuinely improve frequency resolution is to record more samples (longer observation window). Zero-padding does not help here.
Step 2
Choose Your Window
Select based on the application: rectangular for coherent sampling; Hann as the general-purpose default; Blackman for detecting weak signals near strong ones.
Step 3
Zero-Pad for Display
After windowing, zero-pad to a power of 2 for FFT efficiency. This interpolates the spectrum, making the plot smoother — but adds no spectral information.
Step 4
Compensate Window Gain
Windows reduce the apparent signal amplitude. Apply a coherent gain correction (divide by Σ w[n]) to keep amplitude estimates accurate after windowing.

The next lesson covers the Fast Fourier Transform (FFT) — the O(N log N) algorithm that makes DFT computation practical for large N.

Key Takeaways
  • 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.
Previous DFT Definition and Interpretation Module Overview Next Spectral Leakage in Practice