MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / hann

Function hann

numpy_ml/utils/windows.py:76–105  ·  view source on GitHub ↗

The Hann window. Notes ----- The Hann window is an instance of the more general class of cosine-sum windows where `K=1` and :math:`a_0` = 0.5. Unlike the Hamming window, the end points of the Hann window touch zero. .. math:: \\text{hann}(n) = 0.5 - 0.5 \cos\l

(window_len, symmetric=False)

Source from the content-addressed store, hash-verified

74
75
76def hann(window_len, symmetric=False):
77 """
78 The Hann window.
79
80 Notes
81 -----
82 The Hann window is an instance of the more general class of cosine-sum
83 windows where `K=1` and :math:`a_0` = 0.5. Unlike the Hamming window, the
84 end points of the Hann window touch zero.
85
86 .. math::
87
88 \\text{hann}(n) = 0.5 - 0.5 \cos\left(\\frac{2 \pi n}{\\text{window_len} - 1}\\right)
89
90 Parameters
91 ----------
92 window_len : int
93 The length of the window in samples. Should be equal to the
94 `frame_width` if applying to a windowed signal.
95 symmetric : bool
96 If False, create a 'periodic' window that can be used in with an FFT /
97 in spectral analysis. If True, generate a symmetric window that can be
98 used in, e.g., filter design. Default is False.
99
100 Returns
101 -------
102 window : :py:class:`ndarray <numpy.ndarray>` of shape `(window_len,)`
103 The window
104 """
105 return generalized_cosine(window_len, [0.5, 0.5], symmetric)
106
107
108def generalized_cosine(window_len, coefs, symmetric=False):

Callers

nothing calls this directly

Calls 1

generalized_cosineFunction · 0.85

Tested by

no test coverage detected