Window function: Difference between revisions

Content deleted Content added
No edit summary
re-org with section on raised-cosine windows before more complicated families; see talk
Line 131:
{{clear}}
 
=== SineRaised-cosine windowwindows ===
[[File:Window function and frequency response - Cosine.svg|thumb|480px|right|Sine window]]
 
Windows in the form of a cosine function offset by a constant, such as the popular Hamming and Hann windows, are sometimes called raised-cosine windows. The Hann window is particularly like the [[raised cosine distribution]], which goes smoothly to zero at its ends.
:<math>w[n] = \sin\left(\frac{\pi n}{N}\right) = \cos\left(\frac{\pi n}{N} - \frac{\pi}{2}\right),\quad 0\le n \le N.</math>
 
The raised-cosine windows have the form:
The corresponding <math>w_0(n)\,</math> function is a cosine without the {{pi}}/2 phase offset. So the ''sine window''<ref name=Bosi/> is sometimes also called ''cosine window''.<ref name=Harris/> As it represents half a cycle of a sinusoidal function, it is also known variably as ''half-sine window''<ref name=Kido/> or ''half-cosine window''.<ref name=Landisman/>
:<math>w[n] = a_0 - (1-a_0) \cdot \cos\left( \tfrac{2 \pi n}{N} \right),\quad 0\le n \le N,</math>
or alternatively as their zero-phase versions:
:<math>
\begin{align}
w_0(n)\ &= w\left[ n+\tfrac{N}{2}\right]\\
&= a_0 - (1-a_0)\cdot \cos \left ( \tfrac{2\pi n}{N} \right),\quad -\tfrac{N}{2} \le n \le \tfrac{N}{2}.
\end{align}
</math>
 
==== Hann window====
The [[autocorrelation]] of a sine window produces a function known as the Bohman window.<ref name=MWbohman/>
{{Main|Hann function}}
[[File:Window function and its Fourier transform – Hann (n = 0...N).svg|thumb|480px|right|Hann window]]
 
Setting <math>a_0 = 0.5</math> produces a '''Hann window''':
==== Power-of-sine/cosine windows ====
:<math>w[n] = 0.5\; \left[1 - \cos \left ( \frac{2 \pi n}{N} \right) \right] = \sin^2 \left ( \frac{\pi n}{N} \right),</math><ref name=MWhann/>
[[File:Power-of-sine windows.png|thumb|440px|Power-of-sine window functions (left) and their spectra in dB (right), for powers 0, 0.25, 0.5, 1, 2, 4]]
named after [[Julius von Hann]], and sometimes referred to as ''Hanning'', which derived from the verb "to Hann". It is also known as the '''raised cosine''', because of its similarity to a [[raised-cosine distribution]].
 
This function is a member of both the [[#Cosine-sum windows|cosine-sum]] and [[#Power-of-sine/cosine_windows|power-of-sine]] families. Unlike the [[#Hann and Hamming windows|Hamming window]], the end points of the Hann window just touch zero. The resulting [[Spectral leakage|side-lobes]] roll off at about 18&nbsp;dB per octave.<ref name=JOShann/>
These window functions have the form:<ref name=PowCos/>
 
==== Hamming window ====
:<math>w[n] = \sin^\alpha\left(\frac{\pi n}{N}\right) = \cos^\alpha\left(\frac{\pi n}{N} - \frac{\pi}{2}\right),\quad 0\le n \le N.</math>
[[File:Window function and frequency response - Hamming (alpha = 0.53836, n = 0...N).svg|thumb|480px|right|Hamming window, ''a''<sub>0</sub>&nbsp;=&nbsp;0.53836 and ''a''<sub>1</sub>&nbsp;=&nbsp;0.46164. The original Hamming window would have ''a''<sub>0</sub>&nbsp;=&nbsp;0.54 and ''a''<sub>1</sub>&nbsp;=&nbsp;0.46.]]
 
Setting <math>a_0</math> to approximately 0.54, or more precisely 25/46, produces the '''Hamming window''', proposed by [[Richard W.&nbsp;Hamming]]. This choice places a zero crossing at frequency 5{{pi}}/(''N''&nbsp;−&nbsp;1), which cancels the first sidelobe of the Hann window, giving it a height of about one-fifth that of the Hann window.<ref name=Harris/><ref name=Enochson/><ref name=JOSHamming/>
The [[#Rectangular window|rectangular window]] ({{math|1=''α''&nbsp;=&nbsp;0}}), the [[#Sine window|sine window]] ({{math|1=''α''&nbsp;=&nbsp;1}}), and the [[#Hann and Hamming windows|Hann window]] ({{math|1=''α''&nbsp;=&nbsp;2}}) are members of this family.
The Hamming window is often called the '''Hamming blip''' when used for [[pulse shaping]].<ref name=sunar/><ref name=sunar2/><ref name=SRD/>
 
Approximation of the coefficients to two decimal places substantially lowers the level of sidelobes,<ref name=Harris/> to a nearly equiripple condition.<ref name=JOSHamming/> In the equiripple sense, the optimal values for the coefficients are ''a''<sub>0</sub>&nbsp;=&nbsp;0.53836 and ''a''<sub>1</sub>&nbsp;=&nbsp;0.46164.<ref name=JOSHamming/><ref name=Nuttall/>
For even-integer values of {{mvar|α}} these functions can also be expressed in cosine-sum form:
 
: <math>w[n]=a_0 - a_1 \cos \left ( \frac{2 \pi n}{N} \right)+ a_2 \cos \left ( \frac{4 \pi n}{N} \right)- a_3 \cos \left ( \frac{6 \pi n}{N} \right)+ a_4 \cos \left ( \frac{8 \pi n}{N} \right)- ...</math>
: <math>\begin{array}{l|llll}
\hline
\alpha & a_0 & a_1 & a_2 & a_3 & a_4 \\
\hline
0 & 1 \\
2 & 0.5 & 0.5 \\
4 & 0.375 & 0.5 & 0.125 \\
6 & 0.3125 & 0.46875 & 0.1875 & 0.03125 \\
8 & 0.2734375 & 0.4375 & 0.21875 & 0.0625 & 7.8125\times10^{-3} \\
\hline
\end{array}</math>
 
=== Cosine-sum windows ===
This family, which generalizes the [[#Raised-cosine windows|raised-cosine windows]], is also known as ''[generalized cosine windows.<ref>{{cite web | url = https://www.mathworks.com/help/signal/ug/generalized-cosine-windows.html generalized| cosinetitle windows]''.= xxx }}</ref>
 
{{Equation box 1
Line 177 ⟶ 176:
 
In most cases, including the examples below, all coefficients ''a''<sub>''k''</sub>&nbsp;≥&nbsp;0. These windows have only 2''K''&nbsp;+&nbsp;1 non-zero ''N''-point DFT coefficients.
 
==== Hann and Hamming windows{{anchor|Hamming window}} ====
{{Main|Hann function}}
[[File:Window function and its Fourier transform – Hann (n = 0...N).svg|thumb|480px|right|Hann window]]
[[File:Window function and frequency response - Hamming (alpha = 0.53836, n = 0...N).svg|thumb|480px|right|Hamming window, ''a''<sub>0</sub>&nbsp;=&nbsp;0.53836 and ''a''<sub>1</sub>&nbsp;=&nbsp;0.46164. The original Hamming window would have ''a''<sub>0</sub>&nbsp;=&nbsp;0.54 and ''a''<sub>1</sub>&nbsp;=&nbsp;0.46.]]
 
The customary cosine-sum windows for case ''K''&nbsp;=&nbsp;1 have the form
 
:<math>w[n] = a_0 - \underbrace{(1-a_0)}_{a_1}\cdot \cos\left( \tfrac{2 \pi n}{N} \right),\quad 0\le n \le N,</math>
 
which is easily (and often) confused with its zero-phase version:
 
:<math>
\begin{align}
w_0(n)\ &= w\left[ n+\tfrac{N}{2}\right]\\
&= a_0 + a_1\cdot \cos \left ( \tfrac{2\pi n}{N} \right),\quad -\tfrac{N}{2} \le n \le \tfrac{N}{2}.
\end{align}
</math>
 
Setting <math>a_0 = 0.5</math> produces a '''Hann window''':
 
:<math>w[n] = 0.5\; \left[1 - \cos \left ( \frac{2 \pi n}{N} \right) \right] = \sin^2 \left ( \frac{\pi n}{N} \right),</math><ref name=MWhann/>
 
named after [[Julius von Hann]], and sometimes erroneously referred to as ''Hanning'', presumably due to its linguistic and formulaic similarities to the Hamming window. It is also known as '''raised cosine''', because the zero-phase version, <math>w_0(n),</math> is one lobe of an elevated cosine function.
 
This function is a member of both the [[#Cosine-sum windows|cosine-sum]] and [[#Power-of-sine/cosine_windows|power-of-sine]] families. Unlike the [[#Hann and Hamming windows|Hamming window]], the end points of the Hann window just touch zero. The resulting [[Spectral leakage|side-lobes]] roll off at about 18&nbsp;dB per octave.<ref name=JOShann/>
 
Setting <math>a_0</math> to approximately 0.54, or more precisely 25/46, produces the '''Hamming window''', proposed by [[Richard W.&nbsp;Hamming]]. This choice places a zero crossing at frequency 5{{pi}}/(''N''&nbsp;−&nbsp;1), which cancels the first sidelobe of the Hann window, giving it a height of about one-fifth that of the Hann window.<ref name=Harris/><ref name=Enochson/><ref name=JOSHamming/>
The Hamming window is often called the '''Hamming blip''' when used for [[pulse shaping]].<ref name=sunar/><ref name=sunar2/><ref name=SRD/>
 
Approximation of the coefficients to two decimal places substantially lowers the level of sidelobes,<ref name=Harris/> to a nearly equiripple condition.<ref name=JOSHamming/> In the equiripple sense, the optimal values for the coefficients are ''a''<sub>0</sub>&nbsp;=&nbsp;0.53836 and ''a''<sub>1</sub>&nbsp;=&nbsp;0.46164.<ref name=JOSHamming/><ref name=Nuttall/>
 
==== Blackman window ====
Line 241 ⟶ 209:
[[File:Window function and frequency response - Blackman-Harris.svg|thumb|480px|right|Blackman–Harris window]]
 
A generalization of the Hamming family, produced by adding more shifted sinccosine functions, meant to minimize side-lobe levels<ref name=JOSBlack/><ref name=JOSBlack3/>
 
:<math>w[n]=a_0 - a_1 \cos \left ( \frac{2 \pi n}{N} \right)+ a_2 \cos \left ( \frac{4 \pi n}{N} \right)- a_3 \cos \left ( \frac{6 \pi n}{N} \right)</math>
Line 282 ⟶ 250:
Class III is a compromise for which order ''K''&nbsp;=&nbsp;2 resembles the {{slink|#Blackman window}}.<ref name=Andria/><ref name=Schoukens/>
 
{{clear}}
 
=== Sine window ===
[[File:Window function and frequency response - Cosine.svg|thumb|480px|right|Sine window]]
 
:<math>w[n] = \sin\left(\frac{\pi n}{N}\right) = \cos\left(\frac{\pi n}{N} - \frac{\pi}{2}\right),\quad 0\le n \le N.</math>
 
The corresponding <math>w_0(n)\,</math> function is a cosine without the {{pi}}/2 phase offset. So the ''sine window''<ref name=Bosi/> is sometimes also called ''cosine window''.<ref name=Harris/> As it represents half a cycle of a sinusoidal function, it is also known variably as ''half-sine window''<ref name=Kido/> or ''half-cosine window''.<ref name=Landisman/>
 
The [[autocorrelation]] of a sine window produces a function known as the Bohman window.<ref name=MWbohman/>
 
==== Power-of-sine/cosine windows ====
[[File:Power-of-sine windows.png|thumb|440px|Power-of-sine window functions (left) and their spectra in dB (right), for powers 0, 0.25, 0.5, 1, 2, 4]]
 
These window functions have the form:<ref name=PowCos/>
 
:<math>w[n] = \sin^\alpha\left(\frac{\pi n}{N}\right) = \cos^\alpha\left(\frac{\pi n}{N} - \frac{\pi}{2}\right),\quad 0\le n \le N.</math>
 
The [[#Rectangular window|rectangular window]] ({{math|1=''α''&nbsp;=&nbsp;0}}), the [[#Sine window|sine window]] ({{math|1=''α''&nbsp;=&nbsp;1}}), and the [[#Hann and Hamming windows|Hann window]] ({{math|1=''α''&nbsp;=&nbsp;2}}) are members of this family.
 
For even-integer values of {{mvar|α}} these functions can also be expressed in cosine-sum form:
 
: <math>w[n]=a_0 - a_1 \cos \left ( \frac{2 \pi n}{N} \right)+ a_2 \cos \left ( \frac{4 \pi n}{N} \right)- a_3 \cos \left ( \frac{6 \pi n}{N} \right)+ a_4 \cos \left ( \frac{8 \pi n}{N} \right)- ...</math>
: <math>\begin{array}{l|llll}
\hline
\alpha & a_0 & a_1 & a_2 & a_3 & a_4 \\
\hline
0 & 1 \\
2 & 0.5 & 0.5 \\
4 & 0.375 & 0.5 & 0.125 \\
6 & 0.3125 & 0.46875 & 0.1875 & 0.03125 \\
8 & 0.2734375 & 0.4375 & 0.21875 & 0.0625 & 7.8125\times10^{-3} \\
\hline
\end{array}</math>
{{clear}}