# Hann function

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Hann_function
> Markdown URL: https://mediated.wiki/source/Hann_function.md
> Source: https://en.wikipedia.org/wiki/Hann_function
> Source revision: 1328890910
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Mathematical function used in signal processing

Not to be confused with [Hamming function](/source/Hamming_function).

Hann function (left), and its frequency response (right)

The **Hann function** is named after the Austrian meteorologist [Julius von Hann](/source/Julius_von_Hann). It is a [window function](/source/Window_function) used to perform **Hann smoothing** or **hanning**.[1][2] The function, with length L {\displaystyle L} and amplitude 1 / L , {\displaystyle 1/L,} is given by:

- w 0 ( x ) ≜ { 1 L ( 1 2 + 1 2 cos ⁡ ( 2 π x L ) ) = 1 L cos 2 ⁡ ( π x L ) , | x | ≤ L / 2 0 , | x | > L / 2 } . {\displaystyle 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\}.} [a]

For [digital signal processing](/source/Digital_signal_processing), the function is sampled symmetrically (with spacing L / N {\displaystyle L/N} and amplitude 1 {\displaystyle 1} )**:**

- w [ n ] = L ⋅ w 0 ( L N ( n − N / 2 ) ) = 1 2 [ 1 − cos ⁡ ( 2 π n N ) ] = sin 2 ⁡ ( π n N ) } , 0 ≤ n ≤ N , {\displaystyle \left.{\begin{aligned}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{aligned}}\right\},\quad 0\leq n\leq N,}

which is a sequence of N + 1 {\displaystyle N+1} samples, and N {\displaystyle N} can be even or odd. It is also known as the **raised cosine window**, **Hann filter**, **von Hann window**, **Hanning window**, etc.[2][3][4]

## Fourier transform

Top: 16 sample [DFT-even](/source/Spectral_leakage#DFT-symmetry) Hann window.  Bottom: Its discrete-time Fourier transform (DTFT) and the 3 non-zero values of its discrete Fourier transform (DFT).

The [Fourier transform](/source/Fourier_transform) of w 0 ( x ) {\displaystyle w_{0}(x)} is given by:

- W 0 ( f ) = 1 2 sinc ⁡ ( L f ) ( 1 − L 2 f 2 ) = sin ⁡ ( π L f ) 2 π L f ( 1 − L 2 f 2 ) {\displaystyle W_{0}(f)={\frac {1}{2}}{\frac {\operatorname {sinc} (Lf)}{(1-L^{2}f^{2})}}={\frac {\sin(\pi Lf)}{2\pi Lf(1-L^{2}f^{2})}}} [b]

**Derivation**

Using [Euler's formula](/source/Euler's_formula) to expand the cosine term in w 0 ( x ) , {\displaystyle w_{0}(x),} we can write:

- w 0 ( x ) = 1 L ( 1 2 rect ⁡ ( x / L ) + 1 4 e i 2 π x / L rect ⁡ ( x / L ) + 1 4 e − i 2 π x / L rect ⁡ ( x / L ) ) , {\displaystyle w_{0}(x)={\tfrac {1}{L}}\left({\tfrac {1}{2}}\operatorname {rect} (x/L)+{\tfrac {1}{4}}e^{i2\pi x/L}\operatorname {rect} (x/L)+{\tfrac {1}{4}}e^{-i2\pi x/L}\operatorname {rect} (x/L)\right),}

which is a linear combination of modulated [rectangular windows](/source/Rectangular_function):

- 1 L rect ⁡ ( x / L ) ⟷ Fourier transform sinc ⁡ ( L f ) ≜ sin ⁡ ( π L f ) π L f . {\displaystyle {\tfrac {1}{L}}\operatorname {rect} (x/L)\quad {\stackrel {\text{Fourier transform}}{\longleftrightarrow }}\quad \operatorname {sinc} (Lf)\triangleq {\frac {\sin(\pi Lf)}{\pi Lf}}.}

Transforming each term:

- W 0 ( f ) = 1 2 sinc ⁡ ( L f ) + 1 4 sinc ⁡ ( L ( f − 1 / L ) ) + 1 4 sinc ⁡ ( L ( f + 1 / L ) ) = 1 2 sin ⁡ ( π L f ) π L f + 1 4 sin ⁡ ( π ( L f − 1 ) ) π ( L f − 1 ) + 1 4 sin ⁡ ( π ( L f + 1 ) ) π ( L f + 1 ) = 1 2 π ( sin ⁡ ( π L f ) L f − 1 2 sin ⁡ ( π L f ) L f − 1 − 1 2 sin ⁡ ( π L f ) L f + 1 ) = sin ⁡ ( π L f ) 2 π ( 1 L f + 1 2 1 1 − L f − 1 2 1 1 + L f ) = sin ⁡ ( π L f ) 2 π ⋅ 1 L f ( 1 − L f ) ( 1 + L f ) = 1 2 sinc ⁡ ( L f ) ( 1 − L 2 f 2 ) . {\displaystyle {\begin{aligned}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^{2}f^{2})}}.\end{aligned}}}

## Discrete transforms

The [discrete-time Fourier transform](/source/Discrete-time_Fourier_transform) (DTFT) of the N + 1 {\displaystyle N+1} length, time-shifted sequence is defined by a [Fourier series](/source/Fourier_series), which also has a 3-term equivalent that is derived similarly to the Fourier transform derivation:

- F { w [ n ] } ≜ ∑ n = 0 N w [ n ] ⋅ e − i 2 π f n = e − i π f N [ 1 2 sin ⁡ ( π ( N + 1 ) f ) sin ⁡ ( π f ) + 1 4 sin ⁡ ( π ( N + 1 ) ( f − 1 N ) ) sin ⁡ ( π ( f − 1 N ) ) + 1 4 sin ⁡ ( π ( N + 1 ) ( f + 1 N ) ) sin ⁡ ( π ( f + 1 N ) ) ] . {\displaystyle {\begin{aligned}{\mathcal {F}}\{w[n]\}&\triangleq \sum _{n=0}^{N}w[n]\cdot e^{-i2\pi fn}\\&=e^{-i\pi fN}\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{aligned}}}

The truncated sequence { w [ n ] , 0 ≤ n ≤ N − 1 } {\displaystyle \{w[n],\ 0\leq n\leq N-1\}} is a [DFT-even](/source/Spectral_leakage#DFT-symmetry) (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:

- F { w [ n ] } = e − i π f ( N − 1 ) [ 1 2 sin ⁡ ( π N f ) sin ⁡ ( π f ) + 1 4 e − i π / N sin ⁡ ( π N ( f − 1 N ) ) sin ⁡ ( π ( f − 1 N ) ) + 1 4 e i π / N sin ⁡ ( π N ( f + 1 N ) ) sin ⁡ ( π ( f + 1 N ) ) ] . {\displaystyle {\mathcal {F}}\{w[n]\}=e^{-i\pi f(N-1)}\left[{\tfrac {1}{2}}{\frac {\sin(\pi Nf)}{\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 , {\displaystyle f=k/N,} for [integer](/source/Integer) values of k . {\displaystyle 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](/source/Discrete_Fourier_transform#Convolution_theorem_duality).[5][c][d]

## Name

The function is named in honor of von Hann, who used the three-term weighted average smoothing technique on meteorological data.[6][2] However, the term *Hanning* function is also conventionally used,[7] derived from the paper in which the term *hanning a signal* was used to mean applying the Hann window to it.[4][8] It is distinct from the similarly-named [Hamming function](/source/Hamming_function), named after [Richard Hamming](/source/Richard_Hamming).

## See also

- [Window function](/source/Window_function)

- [Apodization](/source/Apodization)

- [Raised cosine distribution](/source/Raised_cosine_distribution)

- [Raised-cosine filter](/source/Raised-cosine_filter)

## Page citations

1. **[^](#cite_ref-3)** [Nuttall 1981](#Nuttall), p 84 (3)

1. **[^](#cite_ref-6)** [Nuttall 1981](#Nuttall), p 86 (17)

1. **[^](#cite_ref-8)** [Nuttall 1981](#Nuttall), p 85

1. **[^](#cite_ref-9)** [Harris 1978](#Harris), p 62

## References

1. **[^](#cite_ref-Essenwanger_1-0)** Essenwanger, O. M. (Oskar M.) (1986). *Elements of statistical analysis*. Elsevier. [ISBN](/source/ISBN_(identifier)) [0444424261](https://en.wikipedia.org/wiki/Special:BookSources/0444424261). [OCLC](/source/OCLC_(identifier)) [152410575](https://search.worldcat.org/oclc/152410575).

1. ^ [***a***](#cite_ref-Kahlig_2-0) [***b***](#cite_ref-Kahlig_2-1) [***c***](#cite_ref-Kahlig_2-2) Kahlig, Peter (1993), ["Some aspects of Julius von Hann's contribution to modern climatology"](https://www.researchgate.net/publication/260824978), in McBean, G.A.; Hantel, M. (eds.), *Interactions Between Global Climate Subsystems: The Legacy of Hann*, Geophysical Monograph Series, vol. 75, American Geophysical Union, pp. 1–7, [doi](/source/Doi_(identifier)):[10.1029/gm075p0001](https://doi.org/10.1029%2Fgm075p0001), [ISBN](/source/ISBN_(identifier)) [9780875904665](https://en.wikipedia.org/wiki/Special:BookSources/9780875904665), retrieved 2019-07-01, Hann appears to be the inventor of a certain data smoothing procedure, now called "hanning" ... or "Hann smoothing" ... Essentially, it is a three-term moving average (running mean) with unequal weights (1/4, 1/2, 1/4).

1. **[^](#cite_ref-Smith_4-0)** Smith, Julius O. (Julius Orion) (2011). [*Spectral audio signal processing*](https://ccrma.stanford.edu/~jos/sasp/Hann_Hanning_Raised_Cosine.html). Stanford University. Center for Computer Research in Music and Acoustics., Stanford University. Department of Music. [Stanford, Calif.?]: W3K. [ISBN](/source/ISBN_(identifier)) [9780974560731](https://en.wikipedia.org/wiki/Special:BookSources/9780974560731). [OCLC](/source/OCLC_(identifier)) [776892709](https://search.worldcat.org/oclc/776892709).

1. ^ [***a***](#cite_ref-Blackman_5-0) [***b***](#cite_ref-Blackman_5-1) [Blackman, R. B.](/source/R._B._Blackman); Tukey, J. W. (1958). "The measurement of power spectra from the point of view of communications engineering — Part I". *The Bell System Technical Journal*. **37** (1): 273. [doi](/source/Doi_(identifier)):[10.1002/j.1538-7305.1958.tb03874.x](https://doi.org/10.1002%2Fj.1538-7305.1958.tb03874.x). [ISSN](/source/ISSN_(identifier)) [0005-8580](https://search.worldcat.org/issn/0005-8580).

1. **[^](#cite_ref-Carlin_7-0)** [US patent 6898235](https://worldwide.espacenet.com/textdoc?DB=EPODOC&IDX=US6898235), 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](https://patentimages.storage.googleapis.com/4d/39/2a/cec2ae6f33c1e7/US6898235.pdf)

1. **[^](#cite_ref-Hann_10-0)** von Hann, Julius (1903). [*Handbook of Climatology*](https://archive.org/details/handbookclimato01wardgoog). Macmillan. p. [199](https://archive.org/details/handbookclimato01wardgoog/page/n219). The figures under *b* are determined by taking into account the parallels 5° away on either side. Thus, for example, for latitude 60° we have ½[60 + (65 + 55)÷2].

1. **[^](#cite_ref-Harris_11-0)** Harris, Fredric J. (Jan 1978). ["On the use of Windows for Harmonic Analysis with the Discrete Fourier Transform"](http://web.mit.edu/xiphmont/Public/windows.pdf) (PDF). *Proceedings of the IEEE*. **66** (1): 51–83. [CiteSeerX](/source/CiteSeerX_(identifier)) [10.1.1.649.9880](https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.649.9880). [doi](/source/Doi_(identifier)):[10.1109/PROC.1978.10837](https://doi.org/10.1109%2FPROC.1978.10837). The correct name of this window is 'Hann.' The term 'Hanning' is used in this report to reflect conventional usage. The derived term 'Hann'd' is also widely used.

1. **[^](#cite_ref-Blackman2_12-0)** [Blackman, R. B. (Ralph Beebe)](/source/Ralph_Beebe_Blackman); Tukey, John W. (John Wilder) (1959). [*The measurement of power spectra from the point of view of communications engineering*](https://archive.org/details/TheMeasurementOfPowerSpectra). New York : Dover Publications. pp. [98](https://archive.org/details/TheMeasurementOfPowerSpectra/page/n58). [LCCN](/source/LCCN_(identifier)) [59-10185](https://lccn.loc.gov/59-10185).{{[cite book](https://en.wikipedia.org/wiki/Template:Cite_book)}}: CS1 maint: publisher location ([link](https://en.wikipedia.org/wiki/Category:CS1_maint:_publisher_location))

1. Nuttall, Albert H. (Feb 1981). ["Some Windows with Very Good Sidelobe Behavior"](https://zenodo.org/record/1280930). *IEEE Transactions on Acoustics, Speech, and Signal Processing*. **29** (1): 84–91. [doi](/source/Doi_(identifier)):[10.1109/TASSP.1981.1163506](https://doi.org/10.1109%2FTASSP.1981.1163506).

## External links

- [Hann function](http://mathworld.wolfram.com/HanningFunction.html) at [MathWorld](/source/MathWorld)

---
Adapted from the Wikipedia article [Hann function](https://en.wikipedia.org/wiki/Hann_function) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Hann_function?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
