Denoising Data with Fast Fourier Transform (FFT)

Welcome back! In the previous lectures, I introduced you to the fast Fourier transform (FFT), a computationally efficient method for analyzing data. In the upcoming videos, I will demonstrate how to implement FFT in MATLAB and Python. To kick things off, let’s start with a simple example: denoising a signal using FFT.

Imagine you have a signal that is the sum of two sine waves, also known as a two-tone signal. Our goal is to compute the FFT of this signal and use it to denoise the data. This way, we can extract the underlying clean signal from the noisy data.

To get started, let’s walk through the MATLAB code. You can download all of the code from the databook UW website.

First, we create a signal in the time domain from 0 to 1 with a delta T of 0.001. Our clean signal is the sum of two sine waves: sine(2pi50t) + sine(2pi120t). We add a relatively large amount of noise to this clean signal, making the amplitudes of the clean signal and noise comparable.

Next, we plot the clean signal (in white) and the noisy signal (in red). Looking at the noisy signal, it might seem challenging to identify the underlying clean signal amidst the noise.

This is where FFT comes into play. In the next section, we compute the FFT of the noisy signal using the FFT command. The FFT function performs the Fourier transform and returns a vector of complex-valued Fourier coefficients. Each coefficient represents a frequency component in the signal. The magnitude of each coefficient indicates the importance of the corresponding frequency, while the phase reveals if it is more cosine or sine in nature.

Further reading:  Machine Learning Control: Optimizing a PID Controller Using Genetic Algorithms

To visualize the power spectrum of the noisy signal, we compute the power spectral density (PSD) by taking the complex conjugate of each coefficient, squared, and dividing by the number of elements. The resulting PSD plot shows the power of each frequency component in the signal, represented on the x-axis in Hertz.

When we analyze the PSD plot, we can clearly identify two dominant peaks corresponding to the frequencies of the original sine waves. The rest of the plot represents the noise floor. This insight gives us a strategy for filtering out the noise.

To apply the denoising filter, we set a threshold of 100 in the PSD plot. Frequencies with power below this threshold are considered noise. We zero out these coefficients, effectively removing them from the signal.

Finally, we inverse Fourier transform the modified coefficients to obtain the denoised signal. Plotting this signal reveals a clean version of the original signal, with the noise effectively eliminated.

Although this example is simplistic, it showcases the power of FFT for denoising and extracting dominant frequency components from real-world noisy data. The ability to filter out noise and recover clean signals has vast applications in various fields.

In conclusion, FFT is a valuable tool in the data scientist’s arsenal. By leveraging the frequency domain representation of a signal, we can successfully denoise and extract important components that may be hidden within noisy data. Stay tuned for more examples and demonstrations of FFT in MATLAB and Python.

If you want to delve deeper into the world of technology and gain insights into the latest trends, be sure to check out Techal. It’s your go-to resource for all things tech!

Further reading:  Singular Value Decomposition (SVD): Unleashing the Power of Data Analysis

Thank you for joining me on this FFT adventure. Remember, the power of FFT lies in its ability to unlock hidden information within noisy data. Until next time!

YouTube video
Denoising Data with Fast Fourier Transform (FFT)