Hubbry Logo
Hann functionHann functionMain
Open search
Hann function
Community hub
Hann function
logo
8 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Hann function
Hann function
from Wikipedia
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.[1][2] The function, with length and amplitude is given by:

  [a]

For digital signal processing, the function is sampled symmetrically (with spacing and amplitude ):

which is a sequence of samples, and 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

[edit]
Top: 16 sample 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 is given by:

  [b]
Derivation

Using Euler's formula to expand the cosine term in we can write:

which is a linear combination of modulated rectangular windows:

Transforming each term:

Discrete transforms

[edit]

The discrete-time Fourier transform (DTFT) of the 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:

The truncated sequence 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:

An N-length DFT of the window function samples the DTFT at frequencies for integer values of 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.[5][c][d]

Name

[edit]

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, named after Richard Hamming.

See also

[edit]

Page citations

[edit]
  1. ^ Nuttall 1981, p 84 (3)
  2. ^ Nuttall 1981, p 86 (17)
  3. ^ Nuttall 1981, p 85
  4. ^ Harris 1978, p 62

References

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
The Hann function, also known as the Hanning window or raised cosine window, is a mathematical employed in to taper the of a finite-length signal, thereby minimizing when performing Fourier transforms. It is named after the Austrian meteorologist Julius von Hann and is characterized by its smooth, bell-shaped curve that starts and ends at zero, providing effective sidelobe suppression while maintaining reasonable frequency resolution. Mathematically, for a discrete signal of length MM, the Hann window is defined as w(n)=0.5[1cos(2πnM1)]w(n) = 0.5 \left[1 - \cos\left(\frac{2\pi n}{M-1}\right)\right] for n=0,1,,M1n = 0, 1, \dots, M-1, which can also be expressed using a sine-squared or raised cosine form. This window function belongs to the family of cosine-based tapers and is particularly valued for its balance of properties in spectral analysis: it exhibits a mainlobe width of 4 bins (between zero crossings), a first sidelobe level of -32 dB, and a sidelobe falloff rate of -18 dB per , making it superior to rectangular windows (-13 dB sidelobes) but with a wider mainlobe than some alternatives like the Hamming window. In practical applications, the Hann window is widely used in (FFT) computations for audio processing, vibration analysis, and spectrum estimation, where it reduces artifacts from non-periodic signals by smoothly attenuating edge discontinuities. Its equivalent bandwidth is 1.5 bins, and it incurs a coherent gain of 0.5, which must be accounted for in amplitude measurements. Compared to other windows, such as the Hamming (which offers better distant sidelobe suppression at -42 dB but similar mainlobe width) or the Blackman (with -58 dB sidelobes but broader mainlobe), the Hann window is often preferred for general-purpose reduction due to its simplicity and computational efficiency. It is implemented in standard libraries like and , where it supports both symmetric (for general tapering) and periodic (for FFT periodicity) variants. Historically, its properties were systematically analyzed in foundational work on window functions for applications, highlighting its role in improving the dynamic range and accuracy of .

Definition and Formulation

Continuous Hann Function

The continuous Hann function serves as a foundational raised cosine window in signal processing, providing a smooth tapering envelope for theoretical analysis of continuous-time signals. It is mathematically defined as w0(x)=12(1+cos2πxL)w_0(x) = \frac{1}{2} \left( 1 + \cos \frac{2\pi x}{L} \right) for xL/2|x| \leq L/2, and w0(x)=0w_0(x) = 0 otherwise, where L>0L > 0 is the length parameter specifying the total width of the support interval. This formulation arises from the raised cosine shape, which inherently produces a periodic cosine curve adjusted to span exactly one full period over the interval [L/2,L/2][-L/2, L/2], ensuring the function transitions smoothly from zero at the boundaries to a peak value of 1 at the center x=0x = 0. Graphically, the continuous Hann function forms a symmetric, bell-shaped centered at the origin, with the gradually increasing from 0 at x=±L/2x = \pm L/2 to the maximum at x=0x = 0, and exhibiting even due to the cosine term. This shape emphasizes the central portion of the signal while suppressing edge discontinuities. In relation to the rectangular window, which is uniform at 1 over the same interval, the continuous Hann function introduces a cosine-based modulation to taper the edges, thereby mitigating effects such as high in frequency-domain representations. The discrete Hann window represents a sampled version of this continuous form for practical digital implementations.

Discrete Hann Window

The discrete Hann window is a finite sequence derived by uniformly sampling the continuous Hann function over an interval of length LL with N+1N+1 points, which provides even symmetry and exact zeros at the endpoints. This formulation is widely used in digital signal processing to taper finite-duration signals while minimizing edge discontinuities. The standard symmetric discrete Hann window is defined as w=12(1cos(2πnN)),0nN,w = \frac{1}{2} \left(1 - \cos\left(\frac{2\pi n}{N}\right)\right), \quad 0 \leq n \leq N, where NN determines the window length L=N+1L = N+1. This yields a sequence with w{{grok:render&&&type=render_inline_citation&&&citation_id=0&&&citation_type=wikipedia}} = 0 and w[N]=0w[N] = 0, ensuring the window tapers smoothly to zero at both ends. An alternative indexing convention defines the window over n=0n = 0 to M1M-1 with M=N+1M = N+1, using the equivalent form w=12(1cos(2πnM1)),w = \frac{1}{2} \left(1 - \cos\left(\frac{2\pi n}{M-1}\right)\right), which maintains the symmetric properties but adjusts the denominator for the finite range. Normalization options include unity peak value (maximum of 1 at the center) or coherent gain of 0.5, corresponding to the average window value, which is the DC gain in the frequency domain. In practice, the discrete Hann window is computed directly using the cosine expression in programming environments, or equivalently via the identity 12(1cosθ)=sin2(θ/2)\frac{1}{2}(1 - \cos \theta) = \sin^2(\theta/2), yielding w=sin2(πnN)w = \sin^2\left(\frac{\pi n}{N}\right), which can offer slight numerical advantages for certain implementations. For example, with N=2N=2 (length 3), the sequence is [0,1,0][0, 1, 0], illustrating the central peak and endpoint zeros. Unlike the continuous Hann function, which is defined over an infinite or semi-infinite domain, the discrete version arises from sampling at points over a closed interval [0, N], inherently producing exact zeros at n=0n=0 and n=Nn=N due to the periodicity of the cosine and the choice of denominator, enhancing for even-length sequences. Common variants include the symmetric form (with endpoint zeros, suitable for ) and the periodic form (designed for spectral analysis via FFT, where the window approximates one full period without forcing endpoint zeros). The periodic variant is generated by evaluating the formula over L+1L+1 points and truncating to length LL, ensuring better continuity in periodic extensions.

Mathematical Properties

Fourier Transform

The continuous Fourier transform of the normalized Hann function, where the time-domain function is scaled by 1/L to ensure unit integral, is given by W0(f)=12\sinc(Lf)1L2f2=sin(πLf)2πLf(1L2f2),W_0(f) = \frac{1}{2} \frac{\sinc(L f)}{1 - L^2 f^2} = \frac{\sin(\pi L f)}{2 \pi L f (1 - L^2 f^2)}, for f±1/Lf \neq \pm 1/L, with appropriate limits at those points. This arises from combining the contributions of the constant and cosine terms in the . To derive this, the cosine in the Hann function w(t)=12[1cos(2πt/L)]w(t) = \frac{1}{2} [1 - \cos(2\pi t / L)] for tL/2|t| \leq L/2 is expressed using as cos(θ)=12[ejθ+ejθ]\cos(\theta) = \frac{1}{2} [e^{j \theta} + e^{-j \theta}], transforming the integral into the of a rectangular WR(f)=L\sinc(Lf)W_R(f) = L \sinc(L f) plus differenced shifted versions at frequencies f±1/Lf \pm 1/L. The resulting sum W(f)=L2\sinc(Lf)L4\sinc(Lf1)L4\sinc(Lf+1)W(f) = \frac{L}{2} \sinc(L f) - \frac{L}{4} \sinc(L f - 1) - \frac{L}{4} \sinc(L f + 1) simplifies to the closed form after algebraic manipulation using trigonometric identities for the sine arguments and common denominator resolution. In the , the central lobe originates from the average value of 1/2 in the time-domain expression, producing a broad sinc-like shape centered at DC, while the cosine modulation introduces interference from the shifted components, manifesting as shaped by the three primary terms at DC and ±1/L\pm 1/L. This structure enhances frequency resolution compared to unwindowed signals by concentrating energy near zero frequency. The exhibit asymptotic decay proportional to 1/f31/f^3, a significant improvement over the rectangular window's 1/f1/f decay, attributable to the Hann function's —being zero at endpoints with a continuous first but discontinuous second . This rapid reduces distant effectively. The 1/L normalization scaling ensures the transform's , particularly the height of the central lobe, remains independent of the window duration L, facilitating consistent spectral analysis across varying signal lengths; without it, amplitudes would scale linearly with L, amplifying low-frequency components disproportionately for longer windows.

Discrete Transforms

The discrete-time Fourier transform (DTFT) of the Hann window sequence ww, defined for the periodic variant as n=0n = 0 to M1M-1 with w=0.5(1cos(2πnM))w = 0.5 \left(1 - \cos\left(\frac{2\pi n}{M}\right)\right), is given by W(f)=n=0M1wej2πfn,W(f) = \sum_{n=0}^{M-1} w e^{-j 2\pi f n}, which simplifies to a closed-form involving three shifted sinc functions: W(f)=12\sinc(fM)+14\sinc((f0.5)M)ejϕ+14\sinc((f+0.5)M)ejϕ,W(f) = \frac{1}{2} \sinc\left(f M\right) + \frac{1}{4} \sinc\left((f - 0.5) M\right) e^{j \phi} + \frac{1}{4} \sinc\left((f + 0.5) M\right) e^{-j \phi}, where \sinc(x)=sin(πx)/(πx)\sinc(x) = \sin(\pi x)/(\pi x) and ϕ=πM(f±0.5)\phi = \pi M (f \pm 0.5) accounts for the linear phase shift due to time centering. Due to the even symmetry of the Hann window around its center, W(f)W(f) is real and even after removing the linear phase term, ensuring phase linearity. The (DFT) of the length-MM Hann sequence samples the DTFT at frequencies f=k/Mf = k/M for integer k=0,,M1k = 0, \dots, M-1, introducing periodic due to the finite length but preserving the overall spectral shape. For the periodic definition using denominator MM in the cosine argument, the DFT exhibits exact sparsity with only three non-zero bins: at k=0k=0 with value 0.5M0.5 M, and at k=1k=1 and k=M1k = M-1 with value 0.25M-0.25 M each (up to the overall scaling by MM), arising from the window's construction as a of DFT basis functions at DC and the adjacent bins; all other bins are exactly zero. This sparsity holds for any M2M \geq 2 and contrasts with denser spectra from the symmetric definition (e.g., denominator M1M-1), where energy leaks slightly beyond three bins. The sparse DFT structure of the Hann window enables efficient computations, such as fast in or spectral analysis, where time-domain windowing corresponds to frequency-domain with a three-tap kernel (non-zeros at bins 0, 1, and M1M-1), reducing complexity from O(M2)O(M^2) to O(M)O(M) per output sample. For example, consider a length-8 Hann window (M=8M=8) with values [0,0.1464,0.5,0.8536,1,0.8536,0.5,0.1464][0, 0.1464, 0.5, 0.8536, 1, 0.8536, 0.5, 0.1464]; its DFT yields non-zero values of 4 at k=0k=0, -2 at k=1k=1, and -2 at k=7k=7, confirming the sparsity and aiding applications like overlap-add methods in audio processing.

Applications and Characteristics

Signal Processing Uses

In digital signal processing, the is commonly applied to time-domain signals prior to computing the (FFT) to mitigate , which arises when analyzing non-periodic or finite-length data segments. By tapering the signal edges to zero, it reduces the discontinuities that cause energy to spread into adjacent frequency bins, thereby improving the accuracy of frequency content estimation in applications such as spectrum analysis. The Hann window plays a key role in overlap-add (OLA) methods, particularly within the (STFT) and filter banks, where signal segments are processed with 50% overlap between consecutive windows. This overlap, combined with the Hann window's symmetric tapering, satisfies the constant overlap-add (COLA) condition, enabling perfect reconstruction of the original signal upon synthesis without distortion or phase errors. As a tapered weighting function, the is used for time-series data by serving as a kernel in weighted moving averages, which diminishes and Gibbs-like oscillations compared to uniform averaging. This approach weights central data points more heavily while gradually reducing influence toward the edges, making it suitable for preprocessing noisy measurements in fields like or . In audio and , the Hann window facilitates analysis of transient sounds, such as in voice recognition systems where STFT frames are windowed to capture frequencies without excessive leakage. Similarly, in monitoring for mechanical systems, it enhances the detection of resonant modes in data by providing balanced resolution for spectra. For image processing, two-dimensional Hann windows are applied to patches for tasks like or frequency-domain filtering, reducing artifacts in Fourier-based operations and preserving moderate in visual signals. For practical implementation, combining the Hann window with zero-padding—appending zeros to the windowed segment before the FFT—yields a finer bin spacing, aiding for peak estimation without altering the underlying resolution limited by the original data length. This technique is particularly useful in real-time systems where computational and visual clarity in spectrograms are prioritized.

Spectral Properties and Performance

The Hann window exhibits a coherent gain of 0.5, meaning the of a coherent component is reduced to half its true value in the (DFT) output. Its equivalent noise bandwidth measures 1.5 bins, indicating that white noise power is spread over 1.5 bins, which moderately broadens the effective resolution compared to a rectangular window. The scalloping loss reaches a maximum of 1.42 dB when a signal falls midway between DFT bins, representing the in detected under worst-case bin misalignment. The sidelobe structure of the Hann window's features a highest sidelobe level of -31 dB relative to the mainlobe peak, providing moderate suppression of from off-bin signals. The sidelobes decay at a rate of 18 dB per , which helps in reducing distant interference but may allow noticeable artifacts in scenarios with strong nearby tones. This profile makes the Hann window suitable for applications where moderate leakage is tolerable, such as general-purpose spectral estimation in audio or vibration analysis.
WindowCoherent GainENBW (bins)Scalloping Loss (dB)Highest Sidelobe (dB)Sidelobe Roll-off (dB/octave)
Rectangular1.01.03.92-13-6
Hann0.51.51.42-31-18
Hamming0.541.361.78-43-6
Blackman0.421.730.82-58-18
The table above compares key spectral metrics, highlighting the Hann window's balance: it offers better sidelobe suppression than the rectangular window (which has prominent -13 dB sidelobes leading to high leakage) but trades off with a narrower mainlobe and lower peak sidelobe than the Hamming window (-43 dB). Relative to the Blackman window, the Hann provides a narrower mainlobe at the cost of higher sidelobes (-31 dB vs. -58 dB), resulting in less effective far-out leakage control but improved frequency resolution. The three-lobe structure of the Hann window's spectrum—comprising a central mainlobe flanked by two smaller adjacent lobes—contributes to relatively smooth amplitude flatness in the when used in (FIR) , minimizing ripples compared to windows with more oscillatory tails. This configuration enhances the frequency response's uniformity for signals, though the wider mainlobe (about twice that of the rectangular window) slightly degrades sharp performance in filtering tasks. Despite its advantages, the Hann window is not optimal for applications requiring very , such as or , where its -31 dB can mask weak targets amid strong returns; in these cases, windows like Blackman or with below -50 dB are preferred.

History and Naming

Origins with Julius von Hann

Julius von Hann (1839–1921), an Austrian and a foundational figure in , introduced a three-term weighted method in his Handbuch der Klimatologie (1883) specifically for analyzing temperature data in meteorological observations. This technique was designed to address irregularities in time series by applying unequal weights to consecutive data points, thereby enhancing the reliability of climatological averages. Hann's approach emerged from his extensive work on global temperature distributions and was particularly suited to handling the limitations of early instrumental records. It was detailed in the first edition (1883) and English translation (1903), and elaborated in the third edition (1908). The original formulation utilized weights of 14\frac{1}{4}, 12\frac{1}{2}, and 14\frac{1}{4} for three consecutive points, creating a simple yet effective that emphasized the central value while tapering the contributions from adjacent points. This weighting is mathematically equivalent to a discrete Hann window of length N=3N=3, providing a rudimentary form of low-pass filtering to suppress high-frequency variations. In practice, Hann applied it to raw readings along latitudinal parallels to derive smoother zonal means, such as obtaining a global average temperature of approximately 14.4°C after processing land-based data. Hann's smoothing procedure was developed in the context of eliminating periodic fluctuations inherent in geophysical , such as diurnal or seasonal cycles that could distort long-term trends in temperature records. By predating , it represented an analog-era innovation reliant on manual computation, yet it proved instrumental in early climatological research for reducing without overly distorting underlying patterns. This discrete weighting scheme later inspired the formulation of the continuous raised cosine function, which extended the tapering concept to analog filtering designs for smoother transitions in signal attenuation during the mid-20th century.

Evolution of Terminology

The term "Hanning window" first appeared in literature during the mid-20th century, notably in the 1958 work by Blackman and Tukey, where it was used to describe the raised cosine window function applied in spectral analysis to mitigate side-lobe effects. Subsequent efforts by organizations such as the (ISO) and the Institute of Electrical and Electronics Engineers (IEEE) have favored the precise term "Hann window" to directly honor its originator, Julius von Hann. For instance, ISO/IEC 14496-3 explicitly defines it as the "Hann window" in the context of audio coding and Fourier transformation. Similarly, IEEE Std 1057-2017 employs "Hann window" in specifications for digitizing waveform recorders, emphasizing its continuous form and derivative properties. A key source of terminological confusion has been its distinction from the Hamming window, which shares a similar raised cosine structure but incorporates a different weighting factor (0.54 for the constant term versus 0.5 for Hann) and was named after Richard W. Hamming to reflect its optimized sidelobe suppression. This overlap led to occasional interchanges in early texts, though the functions differ fundamentally in their spectral characteristics, with the Hamming variant exhibiting slower sidelobe decay. The terminology gained widespread adoption in the 1970s alongside the rise of (FFT) algorithms in , where window functions became essential for leakage reduction. A seminal contribution to standardization came from Harris in , who reviewed various windows and advocated for "Hann" as the accurate designation while documenting "Hanning" as a common but imprecise variant in prior literature. In contemporary usage, "Hann window" predominates in academic and mathematical contexts for its etymological fidelity, whereas "Hanning window" persists in some software legacies, such as MATLAB's original hanning function, which has since been marked obsolete in favor of hann to align with standardized naming. This shift reflects broader efforts to unify terminology across disciplines, reducing ambiguity in implementations like , where hanning was deprecated in 2017 for the preferred hann.

References

Add your contribution
Related Hubs
User Avatar
No comments yet.