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

Function hamming

numpy_ml/utils/windows.py:43–73  ·  view source on GitHub ↗

The Hamming window. Notes ----- The Hamming window is an instance of the more general class of cosine-sum windows where `K=1` and :math:`a_0 = 0.54`. Coefficients selected to minimize the magnitude of the nearest side-lobe in the frequency response. .. math::

(window_len, symmetric=False)

Source from the content-addressed store, hash-verified

41
42
43def hamming(window_len, symmetric=False):
44 """
45 The Hamming window.
46
47 Notes
48 -----
49 The Hamming window is an instance of the more general class of cosine-sum
50 windows where `K=1` and :math:`a_0 = 0.54`. Coefficients selected to
51 minimize the magnitude of the nearest side-lobe in the frequency response.
52
53 .. math::
54
55 \\text{hamming}(n) = 0.54 -
56 0.46 \cos\left(\\frac{2 \pi n}{\\text{window_len} - 1}\\right)
57
58 Parameters
59 ----------
60 window_len : int
61 The length of the window in samples. Should be equal to the
62 `frame_width` if applying to a windowed signal.
63 symmetric : bool
64 If False, create a 'periodic' window that can be used in with an FFT /
65 in spectral analysis. If True, generate a symmetric window that can be
66 used in, e.g., filter design. Default is False.
67
68 Returns
69 -------
70 window : :py:class:`ndarray <numpy.ndarray>` of shape `(window_len,)`
71 The window
72 """
73 return generalized_cosine(window_len, [0.54, 1 - 0.54], symmetric)
74
75
76def hann(window_len, symmetric=False):

Callers

nothing calls this directly

Calls 1

generalized_cosineFunction · 0.85

Tested by

no test coverage detected