Hann function

Mathematical function used in signal processing
title: "Hann function" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["signal-processing"] description: "Mathematical function used in signal processing" topic_path: "engineering" source: "https://en.wikipedia.org/wiki/Hann_function" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Mathematical function used in signal processing ::
::figure[src="https://upload.wikimedia.org/wikipedia/commons/f/f7/Window_function_and_its_Fourier_transform_–Hann(n_=_0...N).svg" caption="Hann function (left), and its frequency response (right)"] ::
The Hann function is named after the Austrian meteorologist Julius von Hann. It is a window function used to perform Hann smoothing or hanning. The function, with length L and amplitude 1/L, is given by: : w_0(x) \triangleq \left{ \begin{array}{ccl} \tfrac{1}{L}\left(\tfrac{1}{2} + \tfrac{1}{2} \cos \left(\frac{2\pi x}{L} \right) \right) = \tfrac{1}{L}\cos^2 \left(\frac{\pi x}{L}\right),\quad &\left|x\right| \leq L/2\ 0,\quad &\left|x\right| L/2 \end{array}\right}.
For digital signal processing, the function is sampled symmetrically (with spacing L/N and amplitude 1): : \left . \begin{align} w[n] = L\cdot w_0\left(\tfrac{L}{N} (n-N/2)\right) &= \tfrac{1}{2} \left[1 - \cos \left ( \tfrac{2 \pi n}{N} \right) \right]\ &= \sin^2 \left ( \tfrac{\pi n}{N} \right) \end{align} \right },\quad 0 \leq n \leq N, which is a sequence of N+1 samples, and N can be even or odd. It is also known as the raised cosine window, Hann filter, von Hann window, Hanning window, etc.
Fourier transform
::figure[src="https://upload.wikimedia.org/wikipedia/commons/9/9b/DFT-even_Hann_window_&_spectral_leakage.png" caption="DFT-even]] Hann window. Bottom: Its discrete-time Fourier transform (DTFT) and the 3 non-zero values of its discrete Fourier transform (DFT)."] ::
The Fourier transform of w_0(x) is given by: : W_0(f) = \frac{1}{2}\frac{\operatorname{sinc}(Lf)}{(1 - L^2f^2)} = \frac{\sin(\pi Lf)}{2\pi L f(1 - L^2f^2)} {{efn-la |Nuttall 1981, p 86 (17)
Using Euler's formula to expand the cosine term in w_0(x), we can write: : w_0(x)= \tfrac{1}{L} \left(\tfrac{1}{2}\operatorname{rect}(x/L) +\tfrac{1}{4} e^{i 2\pi x/L} \operatorname{rect}(x/L) + \tfrac{1}{4}e^{-i 2\pi x/L} \operatorname{rect}(x/L)\right), which is a linear combination of modulated rectangular windows: : \tfrac{1}{L} \operatorname{rect}(x/L)\quad \stackrel{\text{Fourier transform}}{\longleftrightarrow}\quad \operatorname{sinc}(Lf) \triangleq \frac{\sin(\pi L f)}{\pi L f}.
Transforming each term: : \begin{align} W_0(f) &= \tfrac{1}{2}\operatorname{sinc}(Lf) + \tfrac{1}{4} \operatorname{sinc}(L(f-1/L)) + \tfrac{1}{4} \operatorname{sinc}(L(f+1/L))\ &= \tfrac{1}{2}\frac{\sin(\pi Lf)}{\pi Lf} + \tfrac{1}{4} \frac{\sin(\pi (Lf-1))}{\pi (Lf-1)} + \tfrac{1}{4} \frac{\sin(\pi (Lf+1))}{\pi (Lf+1)}\ &= \frac{1}{2\pi}\left( \frac{\sin(\pi Lf)}{Lf} -\tfrac{1}{2} \frac{\sin(\pi Lf)}{Lf-1} -\tfrac{1}{2} \frac{\sin(\pi Lf)}{Lf+1}\right)\ &= \frac{\sin(\pi Lf)}{2\pi}\left(\frac{1}{Lf} +\tfrac{1}{2} \frac{1}{1-Lf} -\tfrac{1}{2} \frac{1}{1+Lf}\right)\ &= \frac{\sin(\pi Lf)}{2\pi}\cdot \frac{1}{Lf (1-Lf) (1+Lf)} = \frac{1}{2}\frac{\operatorname{sinc}(Lf)}{(1 - L^2f^2)}. \end{align}
Discrete transforms
The discrete-time Fourier transform (DTFT) of the N+1 length, time-shifted sequence is defined by a Fourier series, which also has a 3-term equivalent that is derived similarly to the Fourier transform derivation: : \begin{align} \mathcal{F}{w[n]} &\triangleq \sum_{n=0}^{N} w[n]\cdot e^{-i 2 \pi f n}\ &= e^{-i \pi f N}\left[\tfrac{1}{2} \frac{\sin(\pi(N+1)f)}{\sin(\pi f)} + \tfrac{1}{4} \frac{\sin(\pi(N+1)(f-\tfrac{1}{N}))}{\sin(\pi (f-\tfrac{1}{N}))} + \tfrac{1}{4} \frac{\sin(\pi(N+1)(f+\tfrac{1}{N}))}{\sin(\pi (f+\tfrac{1}{N}))}\right]. \end{align}
The truncated sequence {w[n],\ 0 \le n \le N-1} is a DFT-even (aka periodic) Hann window. Since the truncated sample has value zero, it is clear from the Fourier series definition that the DTFTs are equivalent. However, the approach followed above results in a significantly different-looking, but equivalent, 3-term expression: : \mathcal{F}{w[n]} = e^{-i \pi f (N-1)}\left[\tfrac{1}{2} \frac{\sin(\pi N f)}{\sin(\pi f)} + \tfrac{1}{4} e^{-i\pi/N} \frac{\sin(\pi N (f-\tfrac{1}{N}))}{\sin(\pi (f-\tfrac{1}{N}))} + \tfrac{1}{4} e^{i\pi/N} \frac{\sin(\pi N (f+\tfrac{1}{N}))}{\sin(\pi (f+\tfrac{1}{N}))}\right].
An N-length DFT of the window function samples the DTFT at frequencies f = k/N, for integer values of k. From the expression immediately above, it is easy to see that only 3 of the N DFT coefficients are non-zero. And from the other expression, it is apparent that all are real-valued. These properties are appealing for real-time applications that require both windowed and non-windowed (rectangularly windowed) transforms, because the windowed transforms can be efficiently derived from the non-windowed transforms by convolution.{{efn-la |Nuttall 1981, p 85 |Harris 1978, p 62
Name
The function is named in honor of von Hann, who used the three-term weighted average smoothing technique on meteorological data. However, the term Hanning function is also conventionally used, derived from the paper in which the term hanning a signal was used to mean applying the Hann window to it. It is distinct from the similarly-named Hamming function, named after Richard Hamming.
Page citations
References
|ref=refCarlin |title=Wideband communication intercept and direction finding device using hyperchannelization |invent1=Carlin, Joe |invent2=Collins, Terry |invent3=Hays, Peter |invent4=Hemmerdinger, Barry E. Kellogg, Robert L. Kettig, Robert L. Lemmon, Bradley K. Murdock, Thomas E. Tamaru, Robert S. Ware, Stuart M. |pubdate=1999-12-10 |fdate=1999-12-10 |gdate=2005-05-24 |country=US |status=patent |number=6898235 also available at https://patentimages.storage.googleapis.com/4d/39/2a/cec2ae6f33c1e7/US6898235.pdf
- {{cite journal |ref=Nuttall | doi =10.1109/TASSP.1981.1163506 | last =Nuttall | first =Albert H. | title =Some Windows with Very Good Sidelobe Behavior | journal =IEEE Transactions on Acoustics, Speech, and Signal Processing | volume =29 | issue =1 | pages =84–91 | date =Feb 1981 | url =https://zenodo.org/record/1280930
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::