Skip to content
Digital Signal Processing

Spectral analysis: leakage, windows, periodogram and Welch's method

DFT of a finite block and spectral leakage proved, resolution, dynamic range and scalloping loss, zero padding with proof, the periodogram, Welch's method and variance reduction, the spectrogram.

Computing the spectrum of a measured signal looks easy: take a block of samples and compute the FFT. But the result depends on how the block was cut, and on a noisy signal it is surprisingly unreliable. In this lesson we look at spectral leakage with its proof, resolution and scalloping loss, why zero padding does not increase resolution, the periodogram and Welch’s method with the proof of the variance reduction, and the spectrogram.

The DFT of a finite block

When N samples are analysed the signal is observed through a rectangular window, and the DFT gives N samples of the DTFT of the windowed signal, at the frequencies 2\pi k/N (the bins). With sampling frequency f_s the bins are f_s/N apart: with 1 kHz and 1000 samples, 1 Hz.

Theorem. For x[n] = e^{j\omega_0 n}, n = 0, \dots, N-1, the DFT is

    \[ X[k] = \sum_{n=0}^{N-1}e^{j(\omega_0 - 2\pi k/N)n} = e^{j(N-1)\Delta_k/2}\,\frac{\sin(N\Delta_k/2)}{\sin(\Delta_k/2)},\qquad \Delta_k = \omega_0 - \frac{2\pi k}{N} \]

If \omega_0 coincides with a bin, \omega_0 = 2\pi k_0/N, the DFT is N in bin k_0 and zero in all the others; otherwise it is non-zero in every bin.

Proof. It is the same geometric series as the moving average (lesson on the DTFT), with ratio e^{j\Delta_k}. If \omega_0 = 2\pi k_0/N, for k \ne k_0 one has N\Delta_k/2 = \pi(k_0 - k), a multiple of \pi: the sine in the numerator is zero while the one in the denominator is not. For k = k_0 all the terms equal 1. If \omega_0 falls between two bins, N\Delta_k/2 is never a multiple of \pi and no term vanishes. ∎

32-point DFT of a sinusoid falling exactly on a bin and of one falling halfway between two bins
Top, the sinusoid completes an integer number of periods in the block: all its energy is in one bin. Bottom, it completes a non-integer number of periods: the energy spreads over all the bins, with two lower main lines. The dashed curve is the transform of the rectangular window.

This is spectral leakage: a pure sinusoid appears as a peak surrounded by a “skirt” spreading over the whole spectrum, falling off slowly (the side lobes of the rectangular window, the first at −13 dB). The physical reason is that the DFT treats the block as one period of a periodic signal: if the number of periods is not an integer, there is a jump at the junction, and a jump has a wide spectrum.

Resolution, dynamic range and scalloping loss

The consequences are managed with the windows of the FIR lesson, applied this time to the signal:

  • resolution: two sinusoids can be told apart if they are farther apart than the main-lobe width, about 4\pi/N for the rectangular window and 8\pi/N for Hann and Hamming. Resolving close frequencies requires long blocks;
  • dynamic range: a weak sinusoid near a strong one stays hidden in the latter’s side lobes. Windows with low side lobes (Hann, Blackman, Kaiser) make it possible to see components 60-100 dB below;
  • scalloping loss: if the frequency falls halfway between two bins, the measured peak is lower. With the rectangular window the value is 1/(N\sin(\pi/(2N))) \approx 2/\pi, i.e. −3.9 dB. Flat-top windows reduce it below 0.01 dB and are used to measure amplitudes accurately.

Zero padding does not increase resolution

Extending the block with zeros before the FFT (zero padding) produces a denser, smoother plot, but it does not separate two close sinusoids.

Theorem. The N'-point DFT (N' \gt  N) of the zero-padded block gives samples of the same DTFT as the original block, at the frequencies 2\pi k/N'.

Proof. X'[k] = \sum_{n=0}^{N'-1}x'[n]e^{-j2\pi kn/N'} = \sum_{n=0}^{N-1}x[n]e^{-j(2\pi k/N')n}, because the added samples are zero; and this is the DTFT of the original block evaluated at \omega = 2\pi k/N'. ∎

The sampled function is always the same, with the same main lobe: zero padding interpolates, useful to read the position of a peak better, but the information is that of the N measured samples.

The periodogram and Welch’s method

For a random signal, such as noise, what matters is the power spectral density (Signal Theory lesson on random processes). The immediate estimate is the periodogram |X[k]|^2/N. It has a serious flaw: its standard deviation in each bin is of the order of the value itself, and it does not decrease as the block gets longer. More samples give more bins, but each one stays just as noisy: the estimated spectrum of white noise looks like dense grass instead of a flat line.

Welch’s method divides the signal into K segments (often overlapping by 50 %), applies a window to each, computes its periodogram and averages.

Theorem. If the K periodograms are independent and have the same variance \sigma^2, their average has variance \sigma^2/K.

Proof. It is the same result as the mean of n readings (Electrical Measurements lesson on uncertainty): \mathrm{Var}\big(\frac{1}{K}\sum P_i\big) = \frac{1}{K^2}\sum\mathrm{Var}(P_i) = \sigma^2/K. ∎

The price is resolution: each segment is K times shorter. It is the fundamental trade-off of spectral analysis: resolution versus variance, for a given signal duration. Digital spectrum analysers do exactly this, averaging many FFTs.

The spectrogram

For signals that change over time, such as speech or music, the DFT is computed on successive windows and the results are placed side by side: this is the spectrogram (short-time Fourier transform, STFT). A long window gives good frequency resolution but blurs fast events; a short one the opposite. The product of the two resolutions cannot go below a limit, as in the uncertainty principle: \Delta t\,\Delta f is at least of the order of 1. Wavelet transforms choose long windows for low frequencies and short ones for high frequencies, adapting to many natural signals.

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x