Computing FFT and Plotting Frequency Spectrum in Python with NumPy and Matplotlib

Added:

Wavelet Transform and Time-Frequency Analysis

While the Fast Fourier Transform (FFT) is highly efficient for analyzing stationary signals, it has a major limitation: it discards temporal information, making it impossible to determine when specific frequencies occur. For non-stationary signals—such as audio, seismic data, or ECGs where frequencies change over time—the Wavelet Transform offers a superior alternative. Unlike FFT, which uses infinite sinusoidal waves as basis functions, Wavelet Analysis uses localized 'wavelets' that scale and shift. This allows for joint time-frequency representation, providing high temporal resolution for high-frequency events and high frequency resolution for low-frequency events, overcoming the fundamental resolution limits of the Fourier approach.

Basic Python programming skills, including familiarity with NumPy arrays and basic plotting with Matplotlib.
Fundamental concepts of signal processing, such as amplitude, phase, period, and sampling rate (sampling frequency).
The conceptual mathematical definition of the Fourier Transform, specifically the idea of translating a signal from the time domain to the frequency domain.
An understanding of the Nyquist-Shannon sampling theorem and the concept of the Nyquist frequency.
Applying windowing functions (e.g., Hann, Hamming, or Blackman windows) to minimize spectral leakage in FFT analysis.
Implementing the Short-Time Fourier Transform (STFT) and plotting spectrograms to analyze non-stationary signals whose frequency content changes over time.
Designing and implementing digital filters (such as low-pass, high-pass, and band-pass filters) using the SciPy library to clean or manipulate signals.
Exploring practical applications like audio feature extraction (e.g., Mel-Frequency Cepstral Coefficients for speech recognition) or biomedical signal processing (e.g., EEG and ECG analysis).
120.4K views1.6Klikes14:51@1mviews876Original Release: 2020-11-08

This video demonstrates how to compute the Fast Fourier Transform (FFT) of a time-domain signal using Python's numpy.fft.fft function and plot the resulting frequency spectrum using matplotlib. The process involves three main steps: (1) constructing a time-domain signal with specified sampling frequency, signal frequency, and number of samples; (2) performing FFT to obtain complex frequency coefficients, then calculating the magnitude and normalizing by dividing by the number of samples; (3) plotting both the time-domain signal and frequency spectrum, with the latter requiring application of the Nyquist sampling theorem to limit the frequency axis to 0 to half the sampling frequency and proper handling of the DC component. The video shows examples of single-frequency and multi-frequency signals, demonstrating how FFT reveals distinct peaks at each frequency component with magnitudes proportional to their amplitudes.