HannWindow[x]
represents a Hann window function of x.
HannWindow[x,α]
uses the parameter α.
HannWindow
HannWindow[x]
represents a Hann window function of x.
HannWindow[x,α]
uses the parameter α.
Details
- HannWindow is a window function typically used for finite impulse response (FIR) filter design and spectral analysis.
- Window functions are used in applications where data is processed in short segments and have a smoothing effect by gradually tapering data values to zero at the ends of each segment.
- HannWindow[x,α] is equal to
. - HannWindow[x] is equivalent to HannWindow[x,1/2].
- HannWindow automatically threads over lists.
Examples
open all close allBasic Examples (3)
Plot[HannWindow[x], {x, -1, 1}]Plot3D[HannWindow[x]HannWindow[y], {x, -1, 1}, {y, -1, 1}, PlotRange -> All, Exclusions -> None]Extract the continuous function representing the Hann window:
FunctionExpand[HannWindow[x]]FunctionExpand[HannWindow[x, α]]Scope (6)
HannWindow[0.1]Shape of a 1D Hann window using a specified parameter:
Plot[HannWindow[x, 3 / 5], {x, -1, 1}, Exclusions -> None]Variation of the shape as a function of the parameter α:
Plot3D[HannWindow[x, α], {α, 1 / 2, 1}, {x, -1, 1}, Exclusions -> None]Translated and dilated Hann window:
Plot[HannWindow[(x - 1) / 2], {x, -1, 3}]2D Hann window with a circular support:
Plot3D[HannWindow[Sqrt[x ^ 2 + y ^ 2]], {x, -1, 1}, {y, -1, 1}, PlotRange -> All, Exclusions -> None]Discrete Hann window of length 15:
ListPlot[Array[HannWindow, 15, {-1 / 2, 1 / 2}], Filling -> Axis]Discrete 15×10 2D Hann window:
ListPointPlot3D[Array[HannWindow[#1] HannWindow[#2]&, {15, 10}, {{-1 / 2, 1 / 2}}], Filling -> Axis]Applications (4)
Create a lowpass FIR filter with cutoff frequency of
and length 21:
h = LeastSquaresFilterKernel[{"Lowpass", π / 5}, 21]Taper the filter using a Hann window to improve stopband attenuation:
w = Array[HannWindow, Length[h], {-1 / 2, 1 / 2}];
fir = w h;fir / Total[fir]Log-magnitude plot of the power spectra of the two filters:
Plot[Evaluate[20Log[10, Abs@ListFourierSequenceTransform[#, ω]]& /@ {h, %}], {ω, 0, π}, PlotRange -> All, GridLines -> Automatic]Filter a white noise signal using the Hann window method:
a = AudioGenerator["White", 1, SampleRate -> 8000];
Periodogram[{a, LowpassFilter[a, 8000 π / 3, 21, HannWindow]}]Use a window specification to calculate sample PowerSpectralDensity:
proc = ARMAProcess[1, {.5}, {.3}, 1];
data = RandomFunction[proc, {50}];spec = PowerSpectralDensity[data, w, HannWindow];Compare to spectral density calculated without a windowing function:
sd = PowerSpectralDensity[data, w];spec === sdThe plot shows that window smooths the spectral density:
Plot[{sd, spec}, {w, -π, π}, PlotLegends -> {"no window", "with window"}, PlotRange -> All]Compare to the theoretical spectral density of the process:
Plot[{spec, Evaluate@PowerSpectralDensity[proc, w]}, {w, -π, π}, PlotLegends -> {"data", "process"}]Use a window specification for time series estimation:
data = RandomFunction[ARMAProcess[1, {.3}, {.4}, 1], {300}];Specify window for spectral estimator:
EstimatedProcess[data, ARMAProcess[1, 1], ProcessEstimator -> {"SpectralEstimator", "Window" -> HannWindow}]Properties & Relations (6)
HannWindow[x,1] is equivalent to a Dirichlet window:
FunctionExpand[HannWindow[x, 1]] == FunctionExpand[DirichletWindow[x]]HannWindow[x,25/46] is equivalent to a Hamming window:
FunctionExpand[HannWindow[x, 25 / 46]] == FunctionExpand[HammingWindow[x]]The area under the Hann window:
area = Integrate[HannWindow[x], {x, -∞, ∞}]Normalize to create a window with unit area:
Plot[{HannWindow[x], HannWindow[x] / area}, {x, -1, 1}, PlotRange -> All]Fourier transform of the Hann window:
f = FourierTransform[HannWindow[x], x, w]Power spectrum of the Hann window:
LogLinearPlot[20 Log[10, Abs[f]], {w, .1, 80}]Discrete-time Fourier transform of the discrete Hann window of length 11:
f = ListFourierSequenceTransform[Array[HannWindow, 11, {-1 / 2, 1 / 2}], ω, -5]//FullSimplifyf0 = N[f /. ω -> 0]Plot[Abs@f / f0, {ω, 0, π}, PlotRange -> All]Power spectra of the Hann and rectangular windows:
tab = Table[(f = ListFourierSequenceTransform[Array[win, 21, {-1 / 2, 1 / 2}], ω, -10];
f0 = Limit[f, ω -> 0.];
20Log10[Abs@f / f0]), {win, {HannWindow, DirichletWindow}}];LogLinearPlot[tab, {ω, 0.1, π}, PlotRange -> {5, -80}, PlotLegends -> {HannWindow, DirichletWindow}]Possible Issues (1)
2D sampling of Hann window will use a different parameter for each row of samples when passed as a symbol to Array:
Array[HannWindow, {30, 30}, {{-1 / 2, 1 / 2}}]//ListPlot3DArray[HannWindow[#1]HannWindow[#2]&, {30, 30}, {{-1 / 2, 1 / 2}}]//ListPlot3DRelated Guides
History
Text
Wolfram Research (2012), HannWindow, Wolfram Language function, https://reference.wolfram.com/language/ref/HannWindow.html.
CMS
Wolfram Language. 2012. "HannWindow." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HannWindow.html.
APA
Wolfram Language. (2012). HannWindow. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HannWindow.html
BibTeX
@misc{reference.wolfram_2026_hannwindow, author="Wolfram Research", title="{HannWindow}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/HannWindow.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_hannwindow, organization={Wolfram Research}, title={HannWindow}, year={2012}, url={https://reference.wolfram.com/language/ref/HannWindow.html}, note=[Accessed: 13-June-2026]}