mathematics//signal processing//Fourier analysis//discrete Fourier transform
The discrete Fourier transform (DFT) is the computation that takes a finite record of \(N\) samples and returns, for each of \(N\) evenly spaced frequencies, how much of that frequency the record holds and with what phase, and it is the working form of Fourier analysis on any computer: vibration analysers, spectrum displays, audio tools and the FFT block of a drone's firmware all run it. What goes in is a window of samples at rate \(f_s\); what comes out is a complex number per frequency bin.
The discrete Fourier transform (DFT) is the computation that takes a finite record of NNN samples and returns, for each of NNN evenly spaced frequencies, how much of that frequency the record holds and with what phase, and it is the working form of Fourier analysis on any computer: vibration analysers, spectrum displays, audio tools and the FFT block of a drone's firmware all run it. What goes in is a window of samples at rate fsf_sfs; what comes out is a complex number per frequency bin.
Xm=∑n=0N−1xn e−j2πmn/N,Δf=fsN.X_m=\sum_{n=0}^{N-1}x_n\,e^{-j2\pi mn/N},\qquad \Delta f=\frac{f_s}{N}.Xm=n=0∑N−1xne−j2πmn/N,Δf=Nfs.
The magnitude of XmX_mXm is the amount of signal at frequency m Δfm,\Delta fmΔf and its argument is the phase there. The bin spacing Δf\Delta fΔf is the frequency resolution, and since N/fsN/f_sN/fs is the duration of the record, resolution is the inverse of that duration: to separate two lines 0.5 Hz apart, at least 2 s of data are needed, whatever the sampling rate. The rate decides the highest frequency seen (fs/2f_s/2fs/2, the sampling theorem); the duration decides how finely.
Resolution is bought with time.
A machine that must be diagnosed in half a second cannot be read finer than 2 Hz, and a speed that drifts during a long record smears the very lines the long record was meant to separate. Choosing the window length is choosing between those two failures.
The FFT (fast Fourier transform) is an algorithm for the same transform: it computes the same XmX_mXm in on the order of NlogNN\log NNlogN operations instead of N2N^2N2, which is what makes a spectrum of 4,096 points cheap enough to run on a microcontroller several times a second.
A window function prevents spectral leakage. The transform treats the record as if it repeated forever, so a sine that does not fit a whole number of periods into it jumps at the seam and smears its energy into neighbouring bins. Multiplying the record by a taper that falls to zero at both ends (the Hann window is the everyday choice) confines most of the energy near the true line, at the cost of slightly wider peaks.
A bin is an average over the whole record. A brief impact or a transient spreads over many bins with little height in any, which is why bearing defects hide in the plain spectrum and appear in the spectrum of the envelope (envelope analysis), and why a changing signal is read with a spectrogram.
The bins are only as honest as the samples. Content above fs/2f_s/2fs/2 that reached the converter appears in the bins as a real line (aliasing).