A noob learns FFT
The author shares their experience of learning about the Fast Fourier Transform (FFT) for the first time. They describe how they used the FFT function in R to analyze a synthetic 5 Hz sine wave recorded at a sample rate of 100 Hz. The FFT output consisted of 300 complex numbers, with 298 of them sitting at the origin, indicating no signal for those frequencies.
The two points away from the origin suggested the presence of two frequencies, but the author knew the data only contained one. The FFT output is a vector of complex numbers, where the real part represents the cosine signal and the imaginary part represents the sine signal at a given frequency. The author explains that the angle of these complex numbers is less interesting, and the focus should be on the magnitude and phase.
They plot the magnitude of the complex numbers to show the expected amplitude shape of the 5 Hz sine wave signal. The author also discusses the phenomenon of spectral leakage, which occurs when the sample window does not capture a whole number of cycles. They demonstrate how truncation can smear out the clean signal, but note that the original signal can still be perfectly reconstructed.
To mitigate spectral leakage, they apply an envelope function to the data, which attenuates it near the endpoints. The author also shows how adding noise to the signal still allows the FFT to produce a representative spectrum. They proceed to analyze various real-world signal types, such as impulses, step functions, square waves, autoregressive/decaying impulses, and daily and weekly cycles in construction data.
The author concludes by emphasizing the utility of the FFT in analyzing and understanding complex signals.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.