Spectral leakage

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Windowing a sinusoid causes spectral leakage, even if the sinusoid has an integer number of cycles within a rectangular window. The leakage is evident in the 2nd row, blue trace. It is the same amount as the red trace, which represents a slightly higher frequency that does not have an integer number of cycles. When the sinusoid is sampled and windowed, its discrete-time Fourier transform also suffers from the same leakage pattern. But when the DTFT is only sampled, at a certain interval, it is possible (depending on your point of view) to: (1) avoid the leakage, or (2) create the illusion of no leakage. For the case of the blue sinusoid (3rd row of plots, right-hand side), those samples are the outputs of the discrete Fourier transform (DFT). The red sinusoid DTFT (4th row) has the same interval of zero-crossings, but the DFT samples fall in-between them, and the leakage is revealed.

The Fourier transform of a function of time, s(t), is a complex-valued function of frequency, S(f), often referred to as a frequency spectrum. Any linear time-invariant operation on s(t) produces a new spectrum of the form H(f)•S(f), which changes the relative magnitudes and/or angles (phase) of the non-zero values of S(f). Any other type of operation creates new frequency components that may be referred to as spectral leakage in the broadest sense. Sampling, for instance, produces leakage, which we call aliases of the original spectral component. For Fourier transform purposes, sampling is modeled as a product between s(t) and a Dirac comb function. The spectrum of a product is the convolution between S(f) and another function, which inevitably creates the new frequency components. But the term 'leakage' usually refers to the effect of windowing, which is the product of s(t) with a different kind of function, the window function. Window functions happen to have finite duration, but that is not necessary to create leakage. Multiplication by a time-variant function is sufficient.

Leakage caused by a window function is most easily characterized by its effect on a sinusoidal s(t) function, whose unwindowed Fourier transform is zero for all but one frequency. The customary frequency of choice is 0 Hz, because the windowed Fourier transform is simply the Fourier transform of the window function itself:

Discrete-time functions[edit]

When both sampling and windowing are applied to s(t), in either order, the leakage caused by windowing is a relatively localized spreading of frequency components, with often a blurring effect, whereas the aliasing caused by sampling is a periodic repetition of the entire blurred spectrum.

Window tradeoffs[edit]

Comparison of two window functions in terms of their effects on equal-strength sinusoids with additive noise. The sinusoid at bin −20 suffers no scalloping and the one at bin +20.5 exhibits worst-case scalloping. The rectangular window produces the most scalloping but also narrower peaks and lower noise-floor. A third sinusoid with amplitude −16 dB would be noticeable in the upper spectrum, but not in the lower spectrum.

The total leakage of a window function is measured by a metric called equivalent noise bandwidth (ENBW)[1] or noise equivalent bandwidth (NEB). The best window in that regard is the simplest, called rectangular because of its flat top and vertical sides. Its spreading effect occurs mostly a factor of 10 to 100 below the amplitude of the original component. Unfortunately the spreading is very wide, which may mask important spectrum details at even lower levels. That prevents the rectangular window from being a popular choice. Non-rectangular window functions actually increase the total leakage, but they can also redistribute it to places where it does the least harm, depending on the application. Specifically, to different degrees they reduce the level of the spreading by increasing the high-level leakage in the near vicinity of the original component. In general, they control the trade-off between resolving comparable strength signals with similar frequencies or resolving disparate strength signals with dissimilar frequencies: one speaks of "high resolution" versus "high dynamic range" windows. Leakage near the original component is actually beneficial for a metric known as scalloping loss.

We customarily think of leakage as a spreading out of (say) a sinusoid in one "bin" of a DFT into the other bins at levels that generally decrease with distance. What that actually means is that when the actual sinusoid frequency lies in bin "k", its presence is sensed/recorded at different levels in the other bins; i.e. the correlations they measure are non-zero. The value measured in bin k+10 and plotted on the spectrum graph is the response of that measurement to the imperfect (i.e. windowed) sinusoid 10 bins away. And when the input is just white noise (energy at all frequencies), the value measured in bin k is the sum of its responses to a continuum of frequencies. One could say that leakage is actually a leaking in process, rather than leaking out. That perspective might help to interpret the different noise-floor levels between the two graphs in the figure on the right. Both spectra were made from the same data set with the same noise power. But the bins in the bottom graph each responded more strongly than the bins in the top graph. The exact amount of the difference is given by the ENBW difference of the two window functions.

Choice of window function[edit]

Windowing of a simple waveform like cos(ωt) causes its Fourier transform to develop non-zero values (commonly called spectral leakage) at frequencies other than ω. The leakage tends to be worst (highest) near ω and least at frequencies farthest from ω.

If the waveform under analysis comprises two sinusoids of different frequencies, leakage can interfere with our ability to distinguish them spectrally. Possible types of interference are often broken down into two opposing classes as follows: If the component frequencies are dissimilar and one component is weaker, then leakage from the stronger component can obscure the weaker one's presence. But if the frequencies are too similar, leakage can render them unresolvable even when the sinusoids are of equal strength. Windows that are effective against the first type of interference, namely where components have dissimilar frequencies and amplitudes, are called high dynamic range. Conversely, windows that can distinguish components with similar frequencies and amplitudes are called high resolution.

The rectangular window is an example of a window that is high resolution but low dynamic range, meaning it is good for distinguishing components of similar amplitude even when the frequencies are also close, but poor at distinguishing components of different amplitude even when the frequencies are far away. High-resolution, low-dynamic-range windows such as the rectangular window also have the property of high sensitivity, which is the ability to reveal relatively weak sinusoids in the presence of additive random noise. That is because the noise produces a stronger response with high-dynamic-range windows than with high-resolution windows.

At the other extreme of the range of window types are windows with high dynamic range but low resolution and sensitivity. High-dynamic-range windows are most often justified in wideband applications, where the spectrum being analyzed is expected to contain many different components of various amplitudes.

In between the extremes are moderate windows, such as Hamming and Hann. They are commonly used in narrowband applications, such as the spectrum of a telephone channel.

In summary, spectral analysis involves a trade-off between resolving comparable strength components with similar frequencies (high resolution / sensitivity) and resolving disparate strength components with dissimilar frequencies (high dynamic range). That trade-off occurs when the window function is chosen.[2]: p. 90 

Discrete-time signals[edit]

When the input waveform is time-sampled, instead of continuous, the analysis is usually done by applying a window function and then a discrete Fourier transform (DFT). But the DFT provides only a sparse sampling of the actual discrete-time Fourier transform (DTFT) spectrum. Figure 2, row 3 shows a DTFT for a rectangularly-windowed sinusoid. The actual frequency of the sinusoid is indicated as "13" on the horizontal axis. Everything else is leakage, exaggerated by the use of a logarithmic presentation. The unit of frequency is "DFT bins"; that is, the integer values on the frequency axis correspond to the frequencies sampled by the DFT. So the figure depicts a case where the actual frequency of the sinusoid coincides with a DFT sample, and the maximum value of the spectrum is accurately measured by that sample. In row 4, it misses the maximum value by ½ bin, and the resultant measurement error is referred to as scalloping loss (inspired by the shape of the peak). For a known frequency, such as a musical note or a sinusoidal test signal, matching the frequency to a DFT bin can be prearranged by choices of a sampling rate and a window length that results in an integer number of cycles within the window.

Figure 3: This figure compares the processing losses of three window functions for sinusoidal inputs, with both minimum and maximum scalloping loss.

Noise bandwidth[edit]

The concepts of resolution and dynamic range tend to be somewhat subjective, depending on what the user is actually trying to do. But they also tend to be highly correlated with the total leakage, which is quantifiable. It is usually expressed as an equivalent bandwidth, B. It can be thought of as redistributing the DTFT into a rectangular shape with height equal to the spectral maximum and width B.[A][3] The more the leakage, the greater the bandwidth. It is sometimes called noise equivalent bandwidth or equivalent noise bandwidth, because it is proportional to the average power that will be registered by each DFT bin when the input signal contains a random noise component (or is just random noise). A graph of the power spectrum, averaged over time, typically reveals a flat noise floor, caused by this effect. The height of the noise floor is proportional to B. So two different window functions can produce different noise floors.

Processing gain and losses[edit]

In signal processing, operations are chosen to improve some aspect of quality of a signal by exploiting the differences between the signal and the corrupting influences. When the signal is a sinusoid corrupted by additive random noise, spectral analysis distributes the signal and noise components differently, often making it easier to detect the signal's presence or measure certain characteristics, such as amplitude and frequency. Effectively, the signal-to-noise ratio (SNR) is improved by distributing the noise uniformly, while concentrating most of the sinusoid's energy around one frequency. Processing gain is a term often used to describe an SNR improvement. The processing gain of spectral analysis depends on the window function, both its noise bandwidth (B) and its potential scalloping loss. These effects partially offset, because windows with the least scalloping naturally have the most leakage.

Figure 3 depicts the effects of three different window functions on the same data set, comprising two equal strength sinusoids in additive noise. The frequencies of the sinusoids are chosen such that one encounters no scalloping and the other encounters maximum scalloping. Both sinusoids suffer less SNR loss under the Hann window than under the BlackmanHarris window. In general (as mentioned earlier), this is a deterrent to using high-dynamic-range windows in low-dynamic-range applications.

Figure 4: Two different ways to generate an 8-point Gaussian window sequence (σ = 0.4) for spectral analysis applications. MATLAB calls them "symmetric" and "periodic". The latter is also historically called DFT-even.
Figure 5: Spectral leakage characteristics of the functions in Figure 4

Symmetry[edit]

The formulas provided in this article produce discrete sequences, as if a continuous window function has been "sampled". (See an example at Kaiser window.) Window sequences for spectral analysis are either symmetric or 1-sample short of symmetric (called periodic,[4][5] DFT-even, or DFT-symmetric[6]: p. 52 ). For instance, a true symmetric sequence, with its maximum at a single center-point, is generated by the MATLAB function hann(9,'symmetric'). Deleting the last sample produces a sequence identical to hann(8,'periodic'). Similarly, the sequence hann(8,'symmetric') has two equal center-points.[7]

Some functions have one or two zero-valued end-points, which are unnecessary in most applications. Deleting a zero-valued end-point has no effect on its DTFT (spectral leakage). But the function designed for N + 1 or N + 2 samples, in anticipation of deleting one or both end points, typically has a slightly narrower main lobe, slightly higher sidelobes, and a slightly smaller noise-bandwidth.[8]

DFT-symmetry[edit]

The predecessor of the DFT is the finite Fourier transform, and window functions were "always an odd number of points and exhibit even symmetry about the origin".[6]: p.52  In that case, the DTFT is entirely real-valued. When the same sequence is shifted into a DFT data window, the DTFT becomes complex-valued except at frequencies spaced at regular intervals of [a]  Thus, when sampled by an -length DFT, the samples (called DFT coefficients) are still real-valued. An approximation is to truncate the N+1-length sequence (effectively ), and compute an -length DFT. The DTFT (spectral leakage) is slightly affected, but the samples remain real-valued.[9][B] The terms DFT-even and periodic refer to the idea that if the truncated sequence were repeated periodically, it would be even-symmetric about and its DTFT would be entirely real-valued. But the actual DTFT is generally complex-valued, except for the DFT coefficients. In subsequent sections, we sample the DTFT much more densely and display only the magnitude component of the complex numbers.

Periodic summation[edit]

An exact method to sample the DTFT of an N+1-length sequence at intervals of is described at DTFT § L=N+1. Essentially, is combined with (by addition), and an -point DFT is done on the truncated sequence. Similarly, spectral analysis would be done by combining the and data samples before applying the truncated symmetric window. That is not a common practice, even though truncated windows are very popular.[6][10][11][12][13][14][b]

Convolution[edit]

The appeal of DFT-symmetric windows is explained by the popularity of the fast Fourier transform (FFT) algorithm for implementation of the DFT, because truncation of an odd-length sequence results in an even-length sequence. Their real-valued DFT coefficients are also an advantage in certain esoteric applications[C] where windowing is achieved by means of convolution between the DFT coefficients and an unwindowed DFT of the data.[15][6]: p.62 [2]: p.85  In those applications, DFT-symmetric windows (even or odd length) from the Cosine-sum family are preferred, because most of their DFT coefficients are zero-valued, making the convolution very efficient.[D][2]: p.85 

See also[edit]

Notes[edit]

  1. ^ Mathematically, the noise equivalent bandwidth of transfer function H is the bandwidth of an ideal rectangular filter with the same peak gain as H that would pass the same power with white noise input. In the units of frequency f (e.g. hertz), it is given by:
  2. ^ An example of the effect of truncation on spectral leakage is figure Gaussian windows. The graph labeled DTFT periodic8 is the DTFT of the truncated window labeled periodic DFT-even (both blue). The green graph labeled DTFT symmetric9 corresponds to the same window with its symmetry restored. The DTFT samples, labeled DFT8 periodic summation, are an example of using periodic summation to sample it at the same frequencies as the blue graph.
  3. ^ Sometimes both a windowed and an unwindowed (rectangularly windowed) DFT are needed.
  4. ^ For example, see figures DFT-even Hann window and Odd-length, DFT-even Hann window, which show that the -length DFT of the sequence generated by hann(,'periodic') has only three non-zero values. All the other samples coincide with zero-crossings of the DTFT.

Page citations[edit]

  1. ^ Harris 1978, p 52, where
  2. ^ Nuttall 1981, p 85 (15a).

References[edit]

  1. ^ Harris, Fredric j. (Jan 1978). "On the use of Windows for Harmonic Analysis with the Discrete Fourier Transform" (PDF). Proceedings of the IEEE. 66 (1): 51–83. CiteSeerX 10.1.1.649.9880. doi:10.1109/PROC.1978.10837. Article on FFT windows which introduced many of the key metrics used to compare windows.
  2. ^ a b c Nuttall, Albert H. (Feb 1981). "Some Windows with Very Good Sidelobe Behavior". IEEE Transactions on Acoustics, Speech, and Signal Processing. 29 (1): 84–91. doi:10.1109/TASSP.1981.1163506. Extends Harris' paper, covering all the window functions known at the time, along with key metric comparisons.
  3. ^ Carlson, A. Bruce (1986). Communication Systems: An Introduction to Signals and Noise in Electrical Communication. McGraw-Hill. ISBN 978-0-07-009960-9.
  4. ^ "Hann (Hanning) window - MATLAB hann". www.mathworks.com. Retrieved 2020-02-12.
  5. ^ "Window Function". www.mathworks.com. Retrieved 2019-04-14.
  6. ^ a b c d Harris, Fredric J. (Jan 1978). "On the use of Windows for Harmonic Analysis with the Discrete Fourier Transform" (PDF). Proceedings of the IEEE. 66 (1): 51–83. Bibcode:1978IEEEP..66...51H. CiteSeerX 10.1.1.649.9880. doi:10.1109/PROC.1978.10837. S2CID 426548. The fundamental 1978 paper on FFT windows by Harris, which specified many windows and introduced key metrics used to compare them.
  7. ^ Robertson, Neil (18 December 2018). "Evaluate Window Functions for the Discrete Fourier Transform". DSPRelated.com. The Related Media Group. Retrieved 9 August 2020. Revised 22 February 2020.
  8. ^ "Matlab for the Hann Window". ccrma.stanford.edu. Retrieved 2020-09-01.
  9. ^ Rohling, H.; Schuermann, J. (March 1983). "Discrete time window functions with arbitrarily low sidelobe level". Signal Processing. Forschungsinstitut Ulm, Sedanstr, Germany: AEG-Telefunken. 5 (2): 127–138. doi:10.1016/0165-1684(83)90019-1. Retrieved 8 August 2020. It can be shown, that the DFT-even sampling technique as proposed by Harris is not the most suitable one.
  10. ^ Heinzel, G.; Rüdiger, A.; Schilling, R. (2002). Spectrum and spectral density estimation by the Discrete Fourier transform (DFT), including a comprehensive list of window functions and some new flat-top windows (Technical report). Max Planck Institute (MPI) für Gravitationsphysik / Laser Interferometry & Gravitational Wave Astronomy. 395068.0. Retrieved 2013-02-10. Also available at https://pure.mpg.de/rest/items/item_152164_1/component/file_152163/content
  11. ^ Lyons, Richard (1 June 1998). "Windowing Functions Improve FFT Results". EDN. Sunnyvale, CA: TRW. Retrieved 8 August 2020.
  12. ^ Fulton, Trevor (4 March 2008). "DP Numeric Transform Toolbox". herschel.esac.esa.int. Herschel Data Processing. Retrieved 8 August 2020.
  13. ^ Poularikas, A.D. (1999). "7.3.1". In Poularikas, Alexander D. (ed.). The Handbook of Formulas and Tables for Signal Processing (PDF). Boca Raton: CRC Press LLC. ISBN 0849385792. Retrieved 8 August 2020. Windows are even (about the origin) sequences with an odd number of points. The right-most point of the window will be discarded.
  14. ^ Puckette, Miller (30 December 2006). "Fourier analysis of non-periodic signals". msp.ucsd.edu. UC San Diego. Retrieved 9 August 2020.
  15. ^ US patent 6898235, Carlin,Joe; Collins,Terry & Hays,Peter et al., "Wideband communication intercept and direction finding device using hyperchannelization", published 1999-12-10, issued 2005-05-24 , also available at https://patentimages.storage.googleapis.com/4d/39/2a/cec2ae6f33c1e7/US6898235.pdf