Hello! Welcome back.
In our last lesson, we established a crucial hierarchy, seeing the DTFT as the z-transform on the unit circle, and the DFT as a set of uniform samples of the DTFT. This revealed that the DFT, our main computational tool for frequency analysis, gives us only a sampled, discrete view of a signal's true, continuous spectrum.
This naturally leads to the question: what are the practical consequences of this finite, sampled view? What happens if a signal's frequency components don't fall precisely on one of our DFT sample points? This lesson tackles those questions directly. We will explore two fundamental artifacts of practical spectral analysis that arise directly from the nature of the DFT.
Our learning outcome is to analyze spectral leakage and the picket-fence effect in DFT-based spectral analysis.
1. The Root of All Artifacts: Implicit Windowing
When we compute an -point DFT, we are working with a finite sequence of samples. Conceptually, you can think of this finite sequence as being obtained by taking an infinitely long signal, or , and multiplying it by a function that is non-zero only for a finite duration. This function is called a window function.
Even if we don't explicitly apply a window, by simply taking samples and analyzing them, we are implicitly multiplying our signal by a rectangular window. This window has a value of 1 for the duration of our samples and 0 everywhere else.
This multiplication in the time domain has a profound consequence in the frequency domain. From the convolution theorem, we know that multiplication in one domain is equivalent to convolution in the other. Therefore, the spectrum we compute is not the true spectrum of the original signal, but rather the true spectrum convolved with the Fourier transform of the window function.
Understanding the DFT: Spectral Leakage, Windowing, and the DFT of Periodic Signals
The following article, 'Understanding the DFT: Spectral Leakage, Windowing, and the DFT of Periodic Signals', provides a concise mathematical introduction to this core concept. It frames the discussion perfectly by establishing that the implicit rectangular window is the origin of the phenomena we're about to study.
Please read the short introductory sections 'How The Implicit Window Leads to Spectral Leakage' and the first paragraph of 'Spectral Leakage and Periodic Functions'. Focus on the key takeaway: time-domain windowing leads to frequency-domain convolution, which is the source of spectral leakage.
This convolution is the single underlying cause of the artifacts we will now analyze. The shape of the window's spectrum dictates the nature of the distortion we see in our DFT output.
2. Spectral Leakage: Energy Spilling Across Frequencies
The Fourier transform of a rectangular window is a sinc function, characterized by a central "main lobe" and a series of decaying "side lobes." When we convolve our signal's true spectrum with this sinc function, the energy from a single frequency component gets "smeared" or "leaked" across the frequency spectrum, following the shape of the sinc.
Spectral leakage is the phenomenon where the energy of a signal at a single frequency spreads out into adjacent frequency bins in the DFT.
This leakage is dictated by the side lobes of the window's spectrum. The higher the side lobes, the more a signal's energy leaks into neighboring frequencies. This is particularly problematic when a strong signal's leakage completely obscures a nearby, weaker signal.
The video below offers an excellent explanation of this process.
Understanding Signal Analysis using the DTFT Windowing Property
The video 'Understanding Signal Analysis using the DTFT Windowing Property' by Jake Gunther explains the windowing property and introduces the key terminology for analyzing window performance.
Please watch the following segments: 0:00 - 1:37: This introduces the core concept of windowing as convolution. 1:37 - 3:00: This part defines the crucial terms: main lobe, side lobes, main lobe width, and side lobe height. Pay close attention to how the rectangular window has a narrow main lobe but high side lobes. 6:56 - 8:05: This section provides a clear definition of spectral leakage (caused by side lobe height) and resolution (determined by main lobe width).
The key trade-off, which we will explore in the next lesson, is between main lobe width and side lobe height.
- A narrow main lobe gives high resolution, meaning the ability to distinguish between two closely spaced frequencies.
- Low side lobes result in less spectral leakage, meaning the analysis is more sensitive to weak signals in the presence of strong ones.
The rectangular window has the narrowest possible main lobe (best resolution) but very high side lobes (worst leakage).
3. The Picket-Fence Effect: What You Can't See
The second artifact, the picket-fence effect, arises from the DFT's discrete sampling in the frequency domain. The DFT calculates the spectrum at discrete frequency "bins." The true spectrum, however, is continuous (it's the DTFT).
Imagine trying to view a continuous mountain range by peering through the gaps in a picket fence. You can only see what's directly in front of the gaps. If a peak of the mountain range falls behind one of the fence posts, you might miss it entirely or underestimate its height.
This is exactly what happens with the DFT:
- If a signal's true frequency peak falls exactly on a DFT bin, you will measure its correct amplitude.
- If the peak falls between two DFT bins, its energy will be distributed between those two bins, and the measured amplitude in both bins will be lower than the true peak amplitude. This reduction in peak amplitude is often called scalloping loss.
For a more formal and practical definition, especially relevant to your background in electrical engineering, let's turn to an application note from Texas Instruments.
Phase-Compensated, 8-Ch, Multiplexed Data Acquisition System
This document, from a manufacturer of data acquisition systems, provides a very clear, practical definition of these two effects.
Please read section 2.4.1 Picket Fence Effect and Spectral Leakage for Fourier Transform. This section provides concise, industry-standard definitions for both effects.
Mitigating the Picket-Fence Effect with Zero-Padding
As the TI note mentions, we can reduce the picket-fence effect by adding zeros to the end of our time-domain signal before computing the DFT. This is called zero-padding.
Zero-padding to a total length of computes an -point DFT. This doesn't add any new information to the signal, but it results in the DFT being calculated on a finer grid of frequency points instead of . In our analogy, this is like adding more, narrower gaps to our picket fence, giving us a better view of the landscape behind it.
Crucially, zero-padding does not improve resolution. Resolution (the ability to separate two close frequencies) is determined by the length of the original, non-padded time-domain window (). Zero-padding simply interpolates the spectrum, giving a smoother-looking plot and a more accurate estimate of the peak amplitudes and frequencies that were already resolved.
The following video provides an excellent visual demonstration of this concept.
DFT windowing Explanation and Demo
The video 'DFT windowing Explanation and Demo' by David Dorran visually connects the concepts of windowing, convolution, and zero-padding.
Please watch these two key segments: 6:53 - 11:57: This provides the core visualization. It shows how the time-domain multiplication of a sinusoid and a window function corresponds to the frequency-domain convolution of their spectra. This is the origin of leakage. 16:12 - 21:30: This segment demonstrates the effect of zero-padding. It shows how a DFT with fewer points is just a subsampled version of a DFT with more points (achieved by zero-padding). Notice how the underlying shape (the DTFT) remains the same; we are just sampling it more densely.
4. The Special Case: When Leakage Disappears
You might have noticed that sometimes, when analyzing a pure sinusoid, the DFT shows a single, sharp peak with no apparent leakage. This happens under a very specific condition: when the signal completes an integer number of cycles within the N-sample window.
Mathematically, this occurs when the signal frequency is an exact multiple of the DFT's frequency resolution, .
In this case, the implicit periodic extension that the DFT assumes is continuous. In the frequency domain, a remarkable alignment occurs: the peak of the sinc function (from the rectangular window's spectrum) lands exactly on one DFT bin, and all other DFT bins land exactly on the zero-crossings of the sinc function. Thus, we don't "see" the side lobes, and there is no leakage.
The moment the signal's frequency deviates even slightly from being a multiple of , the DFT bins no longer align with the sinc zero-crossings, and the side lobes become visible as leakage.
This is visually explained in Figure 1 of the article from LINK.
This figure from the article "Understanding the DFT..." illustrates the effect of windowing on a single sinusoid. In case A, an integer number of periods is sampled. The DFT frequency bins (blue dots) align perfectly, with only the central peak being non-zero. In case B, a non-integer number of periods is sampled. The bins no longer fall on the sinc function's zero-crossings, and we observe spectral leakage.
The TI application note (LINK) refers to this ideal condition as synchronous sampling. In fields like power systems analysis, significant effort is made to achieve synchronous sampling to get the most accurate phasor measurements, free from leakage artifacts.
Test your understanding!
You are analyzing a signal using a 1024-point DFT. The sampling rate is 48 kHz. Your signal contains two sinusoids:
- Signal A: A strong signal at 10312.5 Hz.
- Signal B: A weak signal at 10500 Hz.
- What is the frequency resolution of your DFT (the spacing between bins)?
- Will Signal A exhibit significant spectral leakage? Why or why not?
- Will Signal B's peak fall directly on a DFT bin? What effect will you observe? How could you get a better estimate of its true amplitude?
- Given the high side lobes of the implicit rectangular window, which signal is more likely to interfere with the measurement of the other?
Show answer
-
The frequency resolution is .
-
To check for leakage, we see if Signal A's frequency is a multiple of the resolution. . Since 220 is an integer, Signal A's frequency falls exactly on bin 220. It completes exactly 220 cycles in the 1024-sample window. Therefore, it will exhibit minimal spectral leakage.
-
Let's check Signal B. . This is also an integer, so Signal B's peak will fall directly on bin 224. In this specific case, you would not observe the picket-fence effect for this signal.
However, if the signal were at 10520 Hz instead, we would get . Its energy would be split between bins 224 and 225, and we would observe the picket-fence effect. To get a better estimate of its true amplitude, we could zero-pad the signal (e.g., to 4096 points) before taking the DFT to interpolate the spectrum between the original bins. -
Signal A is the strong signal. Its spectral leakage (even the small amount that might exist due to noise or slight frequency deviation) would have the potential to spread into nearby bins and could obscure or distort the measurement of the weak Signal B.
Conclusion
In this lesson, we have demystified two of the most common artifacts in practical spectral analysis. You now understand that these are not arbitrary errors but predictable consequences of how the DFT works.
Key Takeaways:
- The DFT implicitly uses a rectangular window, which means the computed spectrum is the true spectrum convolved with a
sincfunction. - Spectral Leakage is the smearing of energy into adjacent frequency bins, caused by the side lobes of the window's spectrum. It obscures weak signals.
- The Picket-Fence Effect is the potential to mis-measure a signal's amplitude and frequency because its peak falls between the DFT's discrete frequency bins.
- Leakage is a consequence of the finite window length (truncation). The picket-fence effect is a consequence of the discrete sampling in the frequency domain.
- These effects are minimized when the signal is periodic within the window (synchronous sampling). Leakage is managed with different window functions, and the picket-fence effect is mitigated by zero-padding.
Preview of the Next Lesson:
We have seen that the rectangular window provides the best resolution but suffers from severe spectral leakage. This suggests a trade-off. Can we find other window functions that offer a better compromise? In our next lesson, we will do just that, as we move to apply various window functions (e.g., Hamming, Hanning) to reduce spectral leakage and analyze their trade-offs.