Saturday 14 November 2015

Intuition for sidelobes in FFT


I was wondering if there's a intuitive way to understand why sidelobes appear when performing an FFT on a signal of fixed length?



Answer



I have two explanations with the intent of providing additional intuitive insight beyond the concise mathematical explanation; first, an explanation from the Fourier Series Expansion along with the idea of repeating the truncated time domain sequence which shows the implied discontinuities that result, requiring more frequency components to reconstruct than would really exist if the waveform was not truncated. And second, an explanation from looking at the DFT as a bank of not-so-great filters.


First Explanation: Fourier Series Expansion and Time Periodicty


The Fourier Transform of a time limited sequence is identical to the Fourier Transform of a sequence that is periodic for all time.


Fourier Transform of a Time Limited Sequence



This is true for the Fourier Transform as well as the Discrete Fourier Transform and is known as the Periodicity Property of the DFT:


Periodicity Property: Given the N-point DFT vector X[k], with an Inverse DFT samples x[n], with both k and n ranging from 0 to N-1; if n lies outside of the range of 0,1,2...,N-1, then


$x[n] = x[modulo(n,N)]$


Likewise, given a N-point time sequence x[n], with a DFT X[k], if k lies outside of the range of 0, 1,2,..., N-1, then


$X[k] = X[modulo(k,N)]$


To help gain an intuitive understanding, a key take-way is that anything that is sampled in one domain, becomes periodic in the other domain. Similarly, anything that is periodic in one domain, becomes sampled (discrete-valued) in the other domain. Here specifically, "sampled" means that the signal will only exist as non-zero values at discrete locations in the domain (stream of impulses).


Sampling in One Domain -> Periodicity in the Other Domain: Consider the spectrum of a 3 Hz analog cosine wave before and after sampling with an A/D converter. The digital spectrum can be viewed as periodic; a cylinder view of the digital spectrum is also a valid view to explain the periodicity, but I find this extension to the analog frequency domain (by having the frequency extend to +/- infinity) helps some gain an intuitive view of the signal processing involved.


ADC Sampling


Periodicity in one Domain -> Sampling in the other Domain: Consider the Fourier Series Expansion as a simple example demonstrating this property. The Fourier Series Expansion is done over a finite time domain interval from 0 to T. When decomposed into separate frequency components, the only frequencies used are DC, the fundamental frequency 1/T, and integer multiples of 1/T (harmonics). In effect, since the frequencies can only exist at multiples of 1/T (and DC), the frequency domain has been sampled.


enter image description here



Further, if we reconstruct the time domain waveform, by summing together the individual frequency components, we can also view the implied periodicity in the time domain if we allow the frequency components to extend beyond the interval 0 to T. It is because of this periodicity that frequency components cannot exist at any other frequencies than multiples of 1/T (because of the opposite condition: if they did exist, then they would not begin and end consistently in the 0 to T time interval, and therefore periodicity cannot exist).


enter image description here


Understanding the above will hopefully help provide an intuitive explanation of spectral leakage. So now I will repeat a main point:


The Fourier Transform of a time limited sequence is identical to the Fourier Transform of a sequence that is periodic for all time.


enter image description here


Spectral Leakage with the "Fourier Series Expansion" View:


Consider two sinusoidal waveforms in the time interval from 0 to T, the first with an integer number of cycles over the time interval, and the second case with a non-integer number of cycles.


enter image description here


enter image description here


enter image description here



Clearly in Case 1 we can see with the repetition view that even repeating our pure sinusoid remains a pure sinusoid, but in Case 2 our sinusoid now suffers from abrupt transitions, and using the Fourier Series Expansion view of reconstruction, would requred several frequency components to reconstruct such a waveform in the time domain.


enter image description here


Second Explanation: Filter Bank View of the DFT


Another intuitive explanation for spectral leakage (and helps significantly with understanding the DFT in general) is what I call the filter bank view of the DFT. To see this, consider a simple 4 pt DFT as shown in the figure below and observe for each bin, we are effectively rotating the signal, and then passing the rotated values through a 4 tap unity gain FIR filter. For the first bin, which corresponds to DC, there is no rotation, so we just sum the four samples, and for the other bins we progressively rotate at higher frequencies as we move through the DFT bins:


enter image description here


(Side note- If we performed a streaming DFT, where we calculated a new 4 point DFT on a 4 point sequence as we scanned through a waveform, it would exactly be such a filter bank, but regardless if we do that or not, this view gives great insight into spectral leakage in addition to the usual convolving of a sinc function in the frequency domain that the mathematical explanation reveals)


enter image description here


Now consider the frequency response for each equivalent FIR filter, using the coefficients given in the DFT (For example use freqz([coeff]) in Matlab or Python) as shown in the figure below:


bank of filters


Here is the main point: Since each Filter in the construction of the DFT is fundamentally a unity gain FIR filter, the shape of this filter in frequency approaches a sinc function as the length of the DFT gets longer (and is an aliased sinc function for small N). So we will call these sinc filters and note that a sinc filter has relatively high sidelobes and has an envelope that rolls off very slowly with frequency (at 1/f for a pure sinc). With the phase rotators in the DFT, we just move the main lobe of this sinc filter to each bin of interest, but the side lobes that exist for each bin allow frequencies at other locations to cause energy to appear in this bin. The amount of leakage is completely predicted by these filters.



Using this view, consider an input single-toned signal with a frequency that is somewhere between two frequency bins as shown in the figure below (an input that exists exactly on any bin will have an integer number of cycles in the time domain interval and therefore NO spectral leakage as we showed earlier). The top filter shows the amplitude at this frequency location that will "leak" to the first bin. The second filter shows the amplitude (slightly higher), the third bin (that our frequency in closest to) will have the highest response and the fourth bin will be lower.


enter image description here


SUMMARY


I have presented two explanations with the intent of providing additional intuitive insight beyond the concise mathematical explanation of multiplication by a rectangular window in the time domain is convolution in the frequency domain (and the leakage we see therefore is the result of a sinc function convolving in frequency with our waveform of interest that we truncated in time); first, an explanation from the Fourier Series Expansion along with the idea of repeating the truncated time domain sequence which shows the implied discontinuities that result, requiring more frequency components to reconstruct than would really exist if the waveform was not truncated. And second, an explanation from looking at the DFT as a bank of filters, and poor filters at that (specifically unity gain filters that approach a sinc function frequency response as N increases). Such filters provide the best frequency resolution but poorest dynamic range.


No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...