Which of the following best explains the cause of spectral leakage when analyzing signals using the Fourier Transform?
Think about what happens when you cut a signal into a short segment before transforming it.
Spectral leakage happens because the Fourier Transform assumes the signal is periodic within the window. If the signal is not exactly periodic in the window length, the discontinuities cause energy to spread to other frequencies.
Given a pure sine wave sampled and transformed using FFT, what is the effect of applying a rectangular window versus a Hann window on the FFT magnitude?
Consider the code below:
import numpy as np import matplotlib.pyplot as plt fs = 1000 f = 50 N = 1000 t = np.arange(N) / fs signal = np.sin(2 * np.pi * f * t) fft_rect = np.fft.fft(signal) window = np.hanning(N) fft_hann = np.fft.fft(signal * window) mag_rect = np.abs(fft_rect)[:N//2] mag_hann = np.abs(fft_hann)[:N//2] peak_rect = np.argmax(mag_rect) peak_hann = np.argmax(mag_hann) print(peak_rect, peak_hann)
Consider that the FFT bin index corresponds to frequency bins. The window affects leakage but not the peak frequency bin.
The peak frequency bin corresponds to the sine wave frequency. Both rectangular and Hann windows keep the peak at the correct bin (50). The Hann window reduces leakage but does not shift the peak.
After applying a rectangular window and a Hann window to the same signal and computing their FFT magnitudes, how does the number of bins with magnitude above 10% of the peak compare?
import numpy as np fs = 1000 f = 50 N = 1000 t = np.arange(N) / fs signal = np.sin(2 * np.pi * f * t) fft_rect = np.fft.fft(signal) window = np.hanning(N) fft_hann = np.fft.fft(signal * window) mag_rect = np.abs(fft_rect)[:N//2] mag_hann = np.abs(fft_hann)[:N//2] threshold_rect = 0.1 * np.max(mag_rect) threshold_hann = 0.1 * np.max(mag_hann) count_rect = np.sum(mag_rect > threshold_rect) count_hann = np.sum(mag_hann > threshold_hann) print(count_rect, count_hann)
Think about how windowing affects the spread of energy in the frequency domain.
The rectangular window causes more spectral leakage, spreading energy across more bins above the threshold. The Hann window reduces leakage, so fewer bins exceed the threshold.
Consider this code snippet that applies a window before FFT but shows unexpected spectral leakage:
import numpy as np fs = 1000 f = 50 N = 1000 t = np.arange(N) / fs signal = np.sin(2 * np.pi * f * t) window = np.hanning(N) fft_result = np.fft.fft(signal) windowed_fft = fft_result * window mag = np.abs(windowed_fft)[:N//2] print(np.argmax(mag))
What is the main error causing incorrect spectral leakage behavior?
Consider when the window should be applied relative to the FFT.
The window must be applied to the time-domain signal before computing the FFT. Applying it after the FFT multiplies frequency components incorrectly, causing wrong spectral leakage behavior.
You have a signal with a frequency of 123.4 Hz sampled at 1000 Hz. You want to analyze it with FFT to minimize spectral leakage. Which window length (N) choice will best reduce leakage?
Think about how window length relates to the signal period and periodicity assumptions in FFT.
Choosing a window length that is an integer multiple of the signal period makes the signal appear periodic within the window, minimizing discontinuities and spectral leakage.