= Hann window
{c}
= Hanning window
{c}
{synonym}
A <Hann window> tapers a record with a raised cosine. For the endpoint-symmetric convention with $N>2$,
$$
w_n=\tfrac12\left[1-\cos\left(\frac{2\pi n}{N-1}\right)\right],\qquad 0\le n<N.
$$
It vanishes at the two stored endpoints. A periodic convention instead uses denominator $N$, corresponding to sampling one cosine period without storing its repeated endpoint. SciPy's primary documentation distinguishes these with `sym=True` and `sym=False`; the default is symmetric.<SciPy 1.16.2 documentation>[scipy.signal.windows.hann, sym parameter, Returns and Notes]{ref} The adjacent <Hanning window> alias also supports the terminology used in older instrument documentation.
An original short-array example makes the difference concrete. At $N=4$, the symmetric coefficients are $(0,3/4,3/4,0)$, while the periodic coefficients are $(0,1/2,1,1/2)$. Their means are $3/8$ and $1/2$. A symmetric even-length array need not contain a coefficient equal to one, despite the nominal raised-cosine peak.
The <coherent gain of a window> is $G_c=N^{-1}\sum_nw_n$. It equals $1/2$ for the periodic Hann convention with $N>1$, and $(N-1)/(2N)$ for the symmetric convention with $N>2$. A coherent complex tone gives windowed DFT magnitude $N|A|G_c$ at its exact bin, so amplitude recovery must use the chosen coefficient sum.
For the periodic convention, its <discrete-time Fourier transform> is obtained from the <rectangular window> transform by modulation:
$$
W_H(\nu)=\tfrac12W_N(\nu)-\tfrac14W_N(\nu-1/N)-\tfrac14W_N(\nu+1/N).
$$
The first central zeros lie at $\nu=\pm2/N$ for the usual $N>3$ case, twice as far from the center as the rectangular window's first zeros. Smooth tapering reduces distant sidelobes while widening the central feature. Nearby frequencies and a weak component far from a strong one can therefore favor different window choices.
Noise normalization is another distinction. For $N>2$, the periodic Hann coefficients obey $\sum_nw_n=N/2$ and $\sum_nw_n^2=3N/8$, giving <equivalent noise bandwidth>
$$
B_e=\frac{N\sum_nw_n^2}{(\sum_nw_n)^2}=\frac32
$$
in DFT bins. The manufacturer's table lists both coherent gain and noise bandwidth.<LabVIEW Analysis Concepts by National Instruments>[Table 5-3, Hanning factors]{ref} Correcting a coherent amplitude does not make noise behave as though the rectangular weights had been used.
The original comparison below evaluates the finite 64-sample periodic Hann and rectangular coefficients at a dense frequency grid, normalizing each response by its own coefficient sum. The extra frequency samples display the same finite-record transform more finely; they do not create a longer observation.
\Image[/rectangular-hann-window-comparison.png]
{title=Original 64-sample rectangular and periodic Hann windows: lower distant sidelobes accompany a wider central lobe}
{description=Each spectral curve is normalized to its own coherent peak. The horizontal frequency axis is measured in DFT-bin offsets. The first positive zeros are at one bin for the rectangular window and two bins for the periodic Hann window.}
Back to article page