A spectrum plot looks like a row of buckets.

Each bar has a frequency label. A signal goes in. Energy lands in the right bucket. The tallest bucket wins.

That picture is convenient and usually wrong.

A DFT bin is not a bucket. It is a test:

how much does this finite record look like this finite sinusoid?

More precisely, each bin is an inner product against one complex exponential on the observation interval. If the signal completes an integer number of cycles inside that interval, one bin can answer cleanly. If it does not, the record looks like a tone with a seam. The seam has to be explained by many finite sinusoids.

That is spectral leakage.

The Record Has Edges

The continuous Fourier transform tempts us to think in infinite signals. A recording, a packet of sensor data, a profiling trace, or a block of audio is not infinite. It is a finite rectangle cut out of time.

Harris’s classic window survey starts from that operational fact: every observed signal we actually process has finite extent, and the DFT gives uniformly spaced samples of the associated periodic spectra.1 The periodic part matters. The DFT treats your length-(N) vector as one lap of a repeating signal.

Suppose the record is

\[x[n] = \cos\left(2\pi \frac{(k+\delta)n}{N} + \phi\right),\]

where (0 < \delta < 1). The tone is between bins. When the record repeats, the last sample does not meet the first sample smoothly. The DFT can represent that repeated object exactly, but it needs energy across many bins to do it.

The leakage is not caused by the FFT algorithm. Cooley and Tukey made the calculation fast in 1965 by factoring the Fourier calculation into sparse stages.2 They did not change what the finite transform measures.

Fast buckets are still not buckets.

The Window Is The Shape Of Listening

Before taking the DFT, we can multiply the record by a window (w[n]):

\[X_w[k] = \sum_{n=0}^{N-1} x[n]w[n]e^{-i2\pi kn/N}.\]

That multiplication changes the filter each bin uses.

For a pure complex tone at frequency (k+\delta), the response of bin (k) is basically the Fourier transform of the window at offset (\delta). A rectangular window listens sharply in the middle but has high sidelobes. A Hann window listens more broadly but pushes far-away sidelobes down. A flat-top window spends even more bandwidth to make amplitude less sensitive to landing between bins.

Harris frames this as a detection and estimation tradeoff. Windows affect nearby strong-tone interference, resolvability, amplitude bias, and broadband noise collection. In his language, the window behaves like a filter and has an equivalent noise bandwidth.1 Heinzel, Ruediger, and Schilling’s practical DFT guide emphasizes the same engineering burden: power spectra and power spectral densities differ by scaling details, with ENBW as one of the important bookkeeping terms.3

So the question is not:

which window removes leakage?

It is:

where do I want the leakage to go, and which bill can I afford?

The Lab

The default experiment uses:

64 samples
strong tone at bin 11.37
weak tone 3.4 bins higher
weak tone amplitude = -38 dB
Hann window
4x zero padding

The lab computes the DFT directly, not with an FFT, because the point is to make the bin inner products visible. The plotted spectrum includes the ordinary integer bins and the denser zero-padded samples.

integer-bin samples zero-padded samples strong tone weak tone bin response

Deterministic direct-DFT experiment. The Node audit runs 21,195 checks: window sums, coherent gain, ENBW, response symmetry, half-bin scalloping, integer-bin replay under zero padding, weak-tone masking, and control sanitization.

Try five moves.

First, set Window to rectangular. The seam in the time panel stays large. The strong off-bin tone throws a tall sidelobe floor into the weak tone’s neighborhood. The weak tone is present in the generated signal, but the strong tone’s leakage is louder than the thing you are trying to see.

Second, switch back to Hann. The weak tone clears the leakage floor. That did not happen because the Hann window has more resolution. It happened because the sidelobes moved down.

Third, switch to flat top. The nearest-bin amplitude becomes almost immune to half-bin placement. But the weak tone can become harder to see because the main lobe is wide and the equivalent noise bandwidth is large. The flat-top window is an amplitude meter, not a free microscope.

Fourth, raise Zero padding. The peak marker gets closer to the actual off-bin frequency. The lobe does not get narrower. Zero padding adds samples of the same continuous-looking window response; it does not add a longer observation.

Fifth, raise Record length. Now the same bin offset corresponds to a longer time record. The main lobe tightens in frequency units. This is the real resolution purchase: observe for longer.

Scalloping Is A Gauge Error

If a tone lands exactly at a bin center, the coherent-gain-corrected peak can recover its amplitude cleanly. If the tone lands halfway between two bins, the nearest bin does not hear it at full strength.

That loss is called scalloping loss. In the lab audit, a rectangular window at a half-bin offset loses about 3.92 dB. A Hann window loses about 1.42 dB. The flat-top window is designed to make that loss nearly vanish.

This is not a contradiction with leakage. It is a different measurement goal.

low sidelobes:        protect weak neighbors from strong-tone leakage
low scalloping loss:  keep tone amplitude stable between bin centers
low ENBW:             collect less broadband noise per bin
narrow main lobe:     separate nearby tones

No single window wins all four contests.

Zero Padding Is Interpolation, Not Evidence

Zero padding is useful. It gives a denser frequency grid, so the sampled peak can sit closer to the true off-bin tone. It makes plots easier to read and simple frequency estimators less jagged.

But it does not create new samples of the original process. The actual record is still (N) observations. If two tones are too close for that observation length and window, padding will draw a smoother blur.

Welch’s spectral-estimation paper is a useful reminder of the larger workflow: practical spectra often section a record, window each section, compute periodograms, and average them to trade variance against time resolution.4 That whole procedure is not “FFT and believe the bar.” It is measurement design.

The Checklist I Want Before Trusting A Peak

When a spectral peak becomes a product decision, a science claim, or a trading signal, I want the boring receipt:

sample rate
record length
window
coherent gain correction
ENBW
zero-padding factor
peak interpolation rule
nearby strong tones
noise floor estimate
whether the question is detection, amplitude, or resolution

Those fields look fussy until a weak line disappears under a sidelobe, or a flat-top amplitude plot convinces someone that two close tones are one object.

The DFT did not lie.

The bin listened with the filter you handed it.

  1. Fredric J. Harris, “On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform”, Proceedings of the IEEE 66(1):51-83, 1978. DOI: 10.1109/PROC.1978.10837 2

  2. James W. Cooley and John W. Tukey, “An Algorithm for the Machine Calculation of Complex Fourier Series”, Mathematics of Computation 19(90):297-301, 1965. DOI: 10.1090/S0025-5718-1965-0178586-1

  3. Gerhard Heinzel, Albrecht Ruediger, and Roland Schilling, “Spectrum and spectral density estimation by the Discrete Fourier transform (DFT), including a comprehensive list of window functions and some new flat-top windows”, Max-Planck-Institut fur Gravitationsphysik technical report, 2002. 

  4. Peter D. Welch, “The Use of Fast Fourier Transform for the Estimation of Power Spectra: A Method Based on Time Averaging Over Short, Modified Periodograms”, IEEE Transactions on Audio and Electroacoustics 15(2):70-73, 1967.