Five windows, one trade: watch the main lobe widen while the highest side lobe sinks.
Five windows, one trade
Each window's shape, and its spectrum |W| in dB relative to its peak, for N = 1024.
Rectangular: the narrowest main lobe, 2 bins, but side lobes from −13.3 dB that fall only 6 dB each time the distance doubles.
Describe this picture
Two panels. The first is the window’s shape, from to against from 0 to 1. The second is its spectrum, in dB relative to its peak from to 0, against the offset from the tone from 0 to 16 bins, for . A bracket under the spectrum’s axis, from 0 to the first zero, is labelled “half the main lobe”, and a dotted level marks the highest side lobe with its value. The readouts are the main lobe, zero to zero, and the highest side lobe.
The clip plays once, in 17 s, and holds on its last frame. It steps through the five windows, cross-fading between them, and the caption says what each one shows. Rectangular: the narrowest main lobe, 2.0 bins, with side lobes from −13.3 dB that fall only 6 dB each time the distance doubles. Hann: 4.0 bins, side lobes from −31.5 dB, falling 18 dB per doubling. Hamming: the same 4.0 bins and a lower first side lobe, −42.7 dB, after which its side lobes fall only 6 dB per doubling. Blackman: 6.0 bins, side lobes from −58.1 dB, falling 18 dB per doubling. Flat-top: 10.0 bins with a flat top, side lobes below −93 dB (the readout is −93.0), and a shape that dips below 0 near the ends. Once the clip has finished, five buttons, a radio group named “Window”, switch the window and show its caption.
Textbooks list dozens, and they sit on one trade
Windowing & spectral leakage (15.1) met three windows: rectangular, Hann and Blackman. Each one lowered the leakage of a tone, and each paid for it with a wider main lobe in the window’s own spectrum. The list in a textbook runs to dozens of windows. Every one of them is a point on that same trade: a wider main lobe buys lower side lobes.
Five numbers describe a window for measurement. Two are the pair from 15.1, the width of the main lobe and the height of the highest side lobe. Roll-off is how many dB the side lobes fall each time the distance from the tone doubles. Scalloping loss is how much a tone halfway between two bins reads low. Coherent gain and equivalent noise bandwidth say how the window scales a tone and noise. I will take them in that order, then put one knob on the whole trade, and end with which window to use for which measurement.
Every window on this page is the one SciPy makes by default, the periodic window. Hann is for to , so its main lobe is exactly 4 bins. NumPy’s np.hanning(N) divides by instead, which is the symmetric form made for filters. For spectra, use the periodic one.
Five windows, one trade
Two more windows join the three. Hamming is : Hann lifted off zero, so that the first side lobe nearly cancels. Flat-top (SciPy’s flattop) is a sum of five cosines,
with weights to of 0.21557895, , 0.277263158, and 0.006947368. It is built for a main lobe with a flat top.
The picture at the top of this page steps through all five. When its clip has finished, press each window in turn and watch the bracket: it grows from 1 bin to 5, half of a main lobe that grows from 2 bins to 10, while the dotted level sinks from −13.3 dB to −93.0 dB. Hamming is the one to watch. Its first side lobe is lower than Hann’s, but its far side lobes are higher: a window trades near leakage for far leakage as well.
At a short length the numbers move a little. For the highest side lobes are , , , and dB for rectangular, Hann, Hamming, Blackman and flat-top, against , , , and at . The pictures and the table below use , which is the textbook large- case.
Between two bins, the peak bar sags
A tone does not sit on a bin unless it is lucky. Say a tone is bins from the nearest bin, with from 0 to 0.5. By Properties of the DTFT (12.3), the window’s spectrum stands in place of the tone’s arrow, so the tallest bar reads the main lobe at , not at its top. The drop is the scalloping loss:
worst at , halfway between two bins. A picket fence in front of a hill shows the same thing. The tallest picket is lower than the hilltop, unless the top is flat.
Watch the flat-top curve: it stays on 0 dB. Halfway between two bins, rectangular reads 3.92 dB low and Hann 1.42 dB.
Between two bins, the peak bar sags
The tallest bar of a tone of amplitude 1, read through three windows, as the tone moves from a bin to halfway between two.
On a bin, every window reads the full amplitude: 0 dB.
Describe this picture
One panel: the tallest bar of a tone of amplitude 1, in dB from to 0.5, against the tone offset from 0 to 0.5 bins, read through three windows. Rectangular is solid with a filled dot, Hann dashed with a filled square and flat-top dotted with a filled diamond; each curve is traced up to the current and labelled at its end. The readouts are the offset and each window’s tallest bar.
The clip plays once, in 11 s, and holds on its last frame. On a bin every window reads the full amplitude, 0 dB, and every readout is 0.00. The tone then slides off the bin, each tallest bar sliding down its window’s main lobe. At a quarter bin, rectangular has lost 0.91 dB, Hann 0.35 dB and flat-top nothing you can see (0.00 dB). The clip ends halfway between bins, the worst case: rectangular reads 3.92 dB low (0.64 of the amplitude), Hann 1.42 dB (0.85) and flat-top 0.01 dB. Afterwards, dragging across the plot or the arrow keys move the tone from 0 to 0.5 bins; the slider is named “Tone offset d”.
The full curve is in numbers too. At , 0.2, 0.25, 0.3 and 0.4, rectangular loses 0.14, 0.58, 0.91, 1.33 and 2.42 dB, and Hann loses 0.06, 0.22, 0.35, 0.51 and 0.91 dB. Flat-top stays within 0.01 dB all the way. At Hamming loses 1.75 dB and Blackman 1.10 dB.
Two scale factors
A tone of amplitude exactly on a bin reads (The DFT, 13.2, gave for the plain cut, where every is 1). The window’s average is its coherent gain:
For Hann it is 0.5. Divide a bin by and you read .
Noise is spread evenly over frequency (Oversampling and noise shaping, 11.3), so a bin collects noise in proportion to the area under . In bins, that area is the equivalent noise bandwidth:
It is 1 bin for the rectangular window and 1.5 bins for Hann. The figure shows why.
Three more rows of the same measure. Read through Hann, Blackman and flat-top windows, the same white noise lands 1.76, 2.37 and 5.76 dB above its level through a rectangular window, when each tone is read with its own coherent gain. The bill for a wide, flat top is a bigger noise bin.
The maths behind it · effective sample size
ENBW is to spectra what the effective sample size is to weighted averages: uneven weights waste data. The ratio is the same one that measures how much a weighted mean’s variance grows over an equal-weight one.
One knob: Kaiser’s β
The Kaiser window puts the whole trade on one dial. With the shape parameter ,
for to , where is the modified Bessel function of order 0, a series that converges quickly. In SciPy it is get_window(('kaiser', beta), N). At the square root does not matter, because , and the window is the rectangular one.
Raising narrows the window in time, widens the main lobe and sinks the side lobes, smoothly. A camera’s aperture ring does the same with one ring: depth of field against light.
Watch the main lobe widen slowly while the side lobes fall fast. At the main lobe is close to Blackman’s width, with side lobes 5 dB lower.
One knob: Kaiser's β
The Kaiser window for N = 1024. β = 0 is the rectangular window.
β = 0: the rectangular window. Main lobe 2 bins, side lobes from −13.3 dB.
Describe this picture
The two panels of the first picture, for the Kaiser window with : the shape (here from 0 to 1.1) and the spectrum with its bracket and dotted level. The readouts are , the main lobe and the highest side lobe. is the rectangular window.
The clip plays once, in 13 s, and holds on its last frame. At the main lobe is 2.00 bins and the side lobes start at −13.3 dB. As rises the window narrows in time, the main lobe widens and the side lobes sink. At the window bows: main lobe 3.24 bins, side lobes from −29.9 dB. The clip ends at : main lobe 5.83 bins, side lobes from −63.3 dB, close to Blackman’s width with 5 dB lower side lobes; one knob slides along the whole trade. Afterwards, dragging across the spectrum or the arrow keys set from 0 to 12; the slider is named “Kaiser β”. At the caption reads “β = 6.0: main lobe 4.31 bins, highest side lobe −43.8 dB.”
For a side-lobe level you want, there is a rule. For a highest side lobe dB below the peak, Kaiser and Schafer give
for from 13.26 to 60, and
for above 60. The main lobe is then close to bins.
For 40 dB the rule gives , and the window it makes reaches dB with a main lobe of 4.02 bins. For 60 dB it gives and dB. For 80 dB it gives , dB and a main lobe of 7.12 bins.
The window table
Everything so far goes into one table for and periodic windows as SciPy makes them.
| Window | Main lobe (bins) | Highest side lobe (dB) | Roll-off (dB per doubling) | CG | ENBW (bins; dB) | Scalloping loss (dB) |
|---|---|---|---|---|---|---|
| Rectangular | 2 | −13.3 | 6 | 1.000 | 1.00; 0.00 | −3.92 |
| Hann | 4 | −31.5 | 18 | 0.500 | 1.50; 1.76 | −1.42 |
| Hamming | 4 | −42.7 | 6 | 0.540 | 1.36; 1.34 | −1.75 |
| Blackman | 6 | −58.1 | 18 | 0.420 | 1.73; 2.37 | −1.10 |
| Flat-top | 10 | −93.0 | none: stays near −93 | 0.216 | 3.77; 5.76 | −0.01 |
| Kaiser, β = 8.6 | 5.83 | −63.3 | 6 | 0.421 | 1.72; 2.36 | −1.11 |
Fig. The five numbers for six windows (N = 1024, periodic windows as SciPy makes them). No row wins every column.
Choosing a window
Use the rule that fits the question.
- Tones exactly on bins, or a transient shorter than the record: rectangular. Nothing leaks when every tone is on a bin, and it has the narrowest main lobe and the lowest noise.
- A first look at an unknown signal: Hann.
- Weak tones near strong ones: Blackman, or Kaiser with from the side-lobe rule.
- Reading a tone’s amplitude: flat-top, with 0.01 dB of scalloping, at the cost of 3.77 bins of noise.
- Two close tones of similar size: the narrowest main lobe that the side lobes allow, so rectangular or Hann.
The maths behind it · banded matrices
A sum-of-cosines window (Hann, Hamming, Blackman, flat-top) is a short vector of weights on the DFT’s columns. Windowing, in the bins, is then a small banded matrix acting on the rectangular window’s bins. Hann’s weights make a three-point filter run along the bins.
Worked example
- Reading a 1 V tone halfway between bins. Through a rectangular window it reads 0.637 V, through Hann 0.849 V and through flat-top 0.999 V. Each is for the loss at .
- Noise per bin. The ENBWs 1.5, 1.727 and 3.770 are 1.76, 2.37 and 5.76 dB.
- Kaiser targets. of 0, 2, 4, 6, 8.6, 10 and 12 give main lobes of 2.00, 2.37, 3.24, 4.31, 5.83, 6.67 and 7.90 bins. Their highest side lobes are , , , , , and dB.
- Short windows. At the highest side lobes are , , , and dB. At they are , , , and .
Where you’ll meet this
Zero-padding and resolution (15.3) separates the reading of the bars from the resolution of the window. Reading a spectrum: scaling and units (15.4) uses and to put numbers on a spectrum. Kaiser windows return in Window-method FIR design (19.1), where NumPy’s symmetric windows belong, and tapers for spectral estimation in The periodogram (25.1).
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Hamming | −42.7 dB, then 6 dB per doubling | |
| Kaiser | : rectangular | |
| Kaiser main lobe | bins | |
| Kaiser for dB side lobes | for ; for | Kaiser and Schafer |
| Coherent gain | tone on a bin reads | |
| ENBW | bins | noise per bin |
| Scalloping loss | worst case, | |
| Choose | bins exact: rectangular; default: Hann; dynamic range: Blackman, Kaiser; amplitude: flat-top |