Hann function: Difference between revisions

Content deleted Content added
m L is the length of the continuous Hann function
 
(35 intermediate revisions by 16 users not shown)
Line 1:
{{Short description|Mathematical function used in signal processing}}
[[File:Window function and its Fourier transform – Hann (n = 0...N).svg|thumb|480px|right|Hann function (left), and its frequency response (right)]]
The '''Hann function''' ofis lengthnamed <math>L,</math>after the Austrian meteorologist [[Julius von Hann]]. It is a [[window function]] used to perform '''Hann smoothing''',.<ref>{{Cite book|urlname=http:Essenwanger//worldcat.org/oclc/152410575|title=Elements> ofThe statistical analysis|last=Essenwangerfunction, O.with M.length (Oskar M.)|date=1986|publisher=Elsevier|isbn=0444424261|oclc=152410575}}<math>L</refmath> isand namedamplitude after the Austrian meteorologist [[Julius von Hann]]<math>1/L,</math> is a [[window function]] given by''':'''
 
:<math>
w_0(x) \triangleq \left\{
\begin{array}{ccl}
\tfrac{1}{2L}\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\}.
</math> &nbsp; {{efn-la |[[#Nuttall|Nuttall 1981]], p 84 (3)}}
</math> &nbsp; <ref name=":0">{{cite journal|last=Harris|first=Fredric J.|date=Jan 1978|title=On the use of Windows for Harmonic Analysis with the Discrete Fourier Transform|url=http://web.mit.edu/xiphmont/Public/windows.pdf|journal=Proceedings of the IEEE|volume=66|issue=1|pages=51–83|citeseerx=10.1.1.649.9880|doi=10.1109/PROC.1978.10837|quote=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.|ref=refHarris|via=}}</ref>
 
For [[digital signal processing]], the function can beis sampled symmetrically as(with spacing <math>L/N</math> and amplitude <math>1</math>)''':'''
 
:<math>
\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}
Line 21:
</math>
 
which is a sequence of <math>N+1</math> samples, and <math>N</math> can be even or odd. (see {{slink|List of window functions|Hann and Hamming windows|nopage=y}}) It is also known as the '''raised cosine window''', '''Hann filter''', '''von Hann window''', etc.<ref name=Kahlig/><ref name=Smith/>
where the length of the window is <math>N+1,</math> and N can be even or odd. (see [[Window function#Hann and Hamming windows]]) It is also known as the '''raised cosine window''', '''Hann filter''', '''von Hann window''', etc.<ref name=":1">{{Citation|last=Kahlig|first=Peter|title=Some aspects of Julius von Hann's contribution to modern climatology|date=1993|url=https://www.researchgate.net/publication/260824978_Some_aspects_of_Julius_von_Hann%27s_contribution_to_modern_climatology|work=Geophysical Monograph Series|volume=75|pages=1–7|editor-last=McBean|editor-first=G.A.|publisher=American Geophysical Union|language=en|doi=10.1029/gm075p0001|isbn=9780875904665|quote=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).|access-date=2019-07-01|editor2-last=Hantel|editor2-first=M.}}</ref><ref>{{Cite book|url=https://ccrma.stanford.edu/~jos/sasp/Hann_Hanning_Raised_Cosine.html|title=Spectral audio signal processing|last=Smith, Julius O. (Julius Orion)|first=|date=2011|publisher=W3K|others=Stanford University. Center for Computer Research in Music and Acoustics., Stanford University. Department of Music.|year=|isbn=9780974560731|location=[Stanford, Calif.?]|pages=|oclc=776892709}}</ref>
 
== Fourier transform ==
 
[[File: DFT-even Hann window & spectral leakage.png|thumb|300px|right|Top: 16 sample [[Window_functionSpectral_leakage#DFT-evensymmetry|DFT-even]] Hann window. Bottom: Its discrete-time Fourier transform (DTFT) and the 3 non-zero values of its discrete Fourier transform (DFT).]]
The Hann window is a linear combination of modulated [[Rectangular_function|rectangular windows]]''':'''
 
The [[Fourier transform]] of <math>w_0(x)</math> is given by:
:<math>\mathrm{rect}(x/L)\quad \stackrel{\text{Fourier transform}}{\longleftrightarrow}\quad L\cdot \mathrm{sinc}(Lf) = \frac{\sin(\pi L f)}{\pi f}.</math>
 
:<math>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)}</math> &nbsp; {{efn-la
Using [[Euler's formula]] to expand the cosine term, we can write''':'''
|[[#Nuttall|Nuttall 1981]], p 86 (17)
}}
{{math proof|title=Derivation|proof=
 
Using [[Euler's formula]] to expand the cosine term in <math>w_0(x),</math> we can write''':'''
:<math>w_0(x)= \tfrac{1}{2}\mathrm{rect}(x/L) +\tfrac{1}{4} e^{i 2\pi x/L} \mathrm{rect}(x/L) + \tfrac{1}{4}e^{-i 2\pi x/L} \mathrm{rect}(x/L),</math>
 
:<math>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),</math>
whose [[Fourier transform]] is just''':'''
 
which is a linear combination of modulated [[Rectangular_function|rectangular windows]]''':'''
:<math>W_0(f) = \tfrac{1}{2}\frac{\sin(\pi Lf)}{\pi f} + \tfrac{1}{4} \frac{\sin(\pi L(f-1/L))}{\pi (f-1/L)} + \tfrac{1}{4} \frac{\sin(\pi L(f+1/L))}{\pi (f+1/L)}.</math>
 
:<math>\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}.</math>
 
Transforming each term''':'''
 
:<math>\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}</math>
}}
 
== Discrete transforms ==
 
The [[Discrete-time Fourier transform]] (DTFT) of the <math>N+1</math> 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''':'''
 
:<math>
Line 49 ⟶ 65:
</math>
 
For even values of N, theThe truncated sequence <math>\{w[n],\ 0 \le n \le N-1\}</math> is a [[Window_functionSpectral_leakage#DFT-evensymmetry|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''':'''
 
:<math>\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].</math>
 
An ''N''-length DFT of the window function samples the DTFT at frequencies <math>f = k/N,</math> for integer values of <math>k.</math> 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 [[Discrete Fourier transform#Convolution theorem duality|convolution]].<ref>{{cite patent |ref=refCarlin |inventor-last name=Carlin |inventor-first=Joe |inventor2-last=Collins |inventor2-first=Terry |inventor3-last=Hays |inventor3-first=Peter |inventor4-last=Hemmerdinger |inventor4-first=Barry |inventor5-last=Kellogg |inventor5-first=Robert |inventor6-last=Kettig |inventor6-first=Robert |inventor7-last=Lemmon |inventor7-first=Bradley |inventor8-last=Murdock |inventor8-first=Thomas |inventor9-last=Tamaru |inventor9-first=Robert |inventor10-last=Ware |inventor10-first=Stuart |date=1999 |issue-date=2005 |title=Wideband communication intercept and direction finding device using hyperchannelization |country-code=US |description=patent |patent-number=6898235}}</ref>{{efn-la
|[[#Nuttall|Nuttall 1981]], p 85
}}{{efn-la
|[[#Harris|Harris 1978]], p 62
}}
 
== Name ==
 
The function is named in honourhonor of von Hann, who used the three-term weighted average smoothing technique on meteorological data.<ref>{{Cite book|url=https://books.google.com/books?id=Ma3PAAAAMAAJ&pg=PA199|title=Handbook of Climatology|lastname=Hann|first=Julius von|date=1903|publisher=Macmillan|year=|isbn=|location=|pages=|language=en|quote=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].}}</ref><ref name=":1" Kahlig/> However, the erroneous<refterm name=":0" /> "''Hanning"'' function is also heardconventionally ofused,<ref on occasion,name=Harris/> derived from the paper in which it was named, where the term "''hanning a signal"'' was used to mean applying the Hann window to it.<ref>{{Cite journal|lastname=Blackman|first=R. B.|last2=Tukey|first2=J. W.|date=1958|title=The measurement of power spectra from the point of view of communications engineering — Part I|url=https://ieeexplore.ieee.org/document/6768513/|journal=The Bell System Technical Journal|volume=37|issue=1|pages=273|doi=10.1002/j.1538-7305.1958.tb03874.x|issn=0005-8580|via=}}</ref><ref>{{Cite book|urlname=https:Blackman2//archive.org/details/TheMeasurementOfPowerSpectra/page/n58|title=The measurement of power spectra from the point of view of communications engineering|last=Blackman|first=R. B. (Ralph Beebe)|last2=Tukey|first2=John W. (John Wilder)|date=1959|publisher=New York : Dover Publications|year=|isbn=|location=|pages=98|lccn=59-10185}}</ref> The confusion arose from the similar [[Hamming function]], named after [[Richard Hamming]].
 
==See also==
Line 63 ⟶ 83:
* [[Apodization]]
* [[Raised cosine distribution]]
* [[Raised-cosine filter]]
 
== Page citations ==
{{notelist-la|1}}
 
==References==
{{reflist|refs=
<references />
<ref name=Essenwanger>
{{Cite book|title=Elements of statistical analysis|last=Essenwanger, O. M. (Oskar M.)|date=1986|publisher=Elsevier|isbn=0444424261|oclc=152410575}}
</ref>
 
<ref name=Harris>
{{cite journal|ref=Harris|last=Harris|first=Fredric J.|date=Jan 1978|title=On the use of Windows for Harmonic Analysis with the Discrete Fourier Transform|url=http://web.mit.edu/xiphmont/Public/windows.pdf|journal=Proceedings of the IEEE|volume=66|issue=1|pages=51–83|citeseerx=10.1.1.649.9880|doi=10.1109/PROC.1978.10837|quote=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.}}
</ref>
 
<ref name=Blackman>
{{Cite journal|last=Blackman|first=R. B.|author-link=R. B. Blackman|last2=Tukey|first2=J. W.|date=1958|title=The measurement of power spectra from the point of view of communications engineering — Part I|journal=The Bell System Technical Journal|volume=37|issue=1|pages=273|doi=10.1002/j.1538-7305.1958.tb03874.x|issn=0005-8580}}
</ref>
 
<ref name=Blackman2>
{{Cite book|url=https://archive.org/details/TheMeasurementOfPowerSpectra|title=The measurement of power spectra from the point of view of communications engineering|last=Blackman|first=R. B. (Ralph Beebe)|author-link=Ralph Beebe Blackman|last2=Tukey|first2=John W. (John Wilder)|date=1959|publisher=New York : Dover Publications|pages=[https://archive.org/details/TheMeasurementOfPowerSpectra/page/n58 98]|lccn=59-10185}}
</ref>
 
<ref name=Kahlig>
{{Citation|last=Kahlig|first=Peter|chapter=Some aspects of Julius von Hann's contribution to modern climatology|date=1993|chapter-url=https://www.researchgate.net/publication/260824978|volume=75|pages=1–7|editor-last=McBean|editor-first=G.A.|publisher=American Geophysical Union|language=en|doi=10.1029/gm075p0001|isbn=9780875904665|quote=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).|access-date=2019-07-01|editor2-last=Hantel|editor2-first=M.|title=Interactions Between Global Climate Subsystems: The Legacy of Hann|series=Geophysical Monograph Series}}
</ref>
 
<ref name=Smith>
{{Cite book|url=https://ccrma.stanford.edu/~jos/sasp/Hann_Hanning_Raised_Cosine.html|title=Spectral audio signal processing|last=Smith, Julius O. (Julius Orion)|date=2011|publisher=W3K|others=Stanford University. Center for Computer Research in Music and Acoustics., Stanford University. Department of Music.|isbn=9780974560731|location=[Stanford, Calif.?]|oclc=776892709}}
</ref>
 
<ref name=Carlin>
{{cite patent
|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
}}, <!--template creates link to worldwide.espacenet.com-->
also available at https://patentimages.storage.googleapis.com/4d/39/2a/cec2ae6f33c1e7/US6898235.pdf
</ref>
 
<ref name=Hann>
{{Cite book |last=von Hann |first=Julius |url=https://archive.org/details/handbookclimato01wardgoog |page=[https://archive.org/details/handbookclimato01wardgoog/page/n219 199] |title=Handbook of Climatology |date=1903 |publisher=Macmillan |language=en |quote=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&nbsp;+&nbsp;(65&nbsp;+&nbsp;55)÷2].}}
</ref>
}}
 
{{refbegin}}
#<li value="9">{{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
}}
{{refend}}
 
== External links ==