1. The basics
Written on February, 2025 by Bolton TranFourier transform is a common technique used in signal processing. Its applications extend to physics and chemistry, particularly in molecular simulations where thermal fluctuation can muddle the observables (e.g., energy, atomic position). We will explore the basics of Fourier transform here, before jumping into some applications in subsequent posts.
Note that the math of Fourier transform is better documented else where (e.g., Wolfram). I want to simply outline the practical use of Fourier transform in this tutorial.
Let’s consider a periodic time series,
following a sine function with some frequency and amplitude.
Consider next random noise
that blurs the periodicity of this time series.
How may we recover the frequency and amplitude
of the original signal (i.e., the sine function)?
$\rightarrow$ Fourier transform converts the time series into a frequency space,
allowing for quick discerning of the periodicity in our signal.
Using Python, I constructed below an example of a sine time series with random Gaussian noise. Playing with the interactive plot below should give a better visualization of what Fourier transform entails.
import numpy as np
import matplotlib.pyplot as plt
from scipy.fft import rfft, rfftfreq
#Define time range
dt=0.001 #step size
time=np.arange(0, 1, dt)
#Create signal as a sine function with random Gaussian noise
freq=5
amplitude=2
noise=1
signal=amplitude*np.sin(2*np.pi*freq*time) + noise*np.random.randn(len(time))
#(Discrete) Fourier transform
yf=rfft(signal)
freqs=rfftfreq(len(signal), dt)
#Plot
plt.figure()
plt.plot(t, signal) #signal in real time
plt.figure()
plt.plot(freqs, np.abs(yf)) #signal in frequency
plt.show()