MCPcopy Index your code
hub / github.com/numpy/numpy / hamming

Function hamming

numpy/lib/_function_base_impl.py:3358–3453  ·  view source on GitHub ↗

Return the Hamming window. The Hamming window is a taper formed by using a weighted cosine. Parameters ---------- M : int Number of points in the output window. If zero or less, an empty array is returned. Returns ------- out : ndarray The

(M)

Source from the content-addressed store, hash-verified

3356
3357@set_module('numpy')
3358def hamming(M):
3359 """
3360 Return the Hamming window.
3361
3362 The Hamming window is a taper formed by using a weighted cosine.
3363
3364 Parameters
3365 ----------
3366 M : int
3367 Number of points in the output window. If zero or less, an
3368 empty array is returned.
3369
3370 Returns
3371 -------
3372 out : ndarray
3373 The window, with the maximum value normalized to one (the value
3374 one appears only if the number of samples is odd).
3375
3376 See Also
3377 --------
3378 bartlett, blackman, hanning, kaiser
3379
3380 Notes
3381 -----
3382 The Hamming window is defined as
3383
3384 .. math:: w(n) = 0.54 - 0.46\\cos\\left(\\frac{2\\pi{n}}{M-1}\\right)
3385 \\qquad 0 \\leq n \\leq M-1
3386
3387 The Hamming was named for R. W. Hamming, an associate of J. W. Tukey
3388 and is described in Blackman and Tukey. It was recommended for
3389 smoothing the truncated autocovariance function in the time domain.
3390 Most references to the Hamming window come from the signal processing
3391 literature, where it is used as one of many windowing functions for
3392 smoothing values. It is also known as an apodization (which means
3393 "removing the foot", i.e. smoothing discontinuities at the beginning
3394 and end of the sampled signal) or tapering function.
3395
3396 References
3397 ----------
3398 .. [1] Blackman, R.B. and Tukey, J.W., (1958) The measurement of power
3399 spectra, Dover Publications, New York.
3400 .. [2] E.R. Kanasewich, "Time Sequence Analysis in Geophysics", The
3401 University of Alberta Press, 1975, pp. 109-110.
3402 .. [3] Wikipedia, "Window function",
3403 https://en.wikipedia.org/wiki/Window_function
3404 .. [4] W.H. Press, B.P. Flannery, S.A. Teukolsky, and W.T. Vetterling,
3405 "Numerical Recipes", Cambridge University Press, 1986, page 425.
3406
3407 Examples
3408 --------
3409 >>> import numpy as np
3410 >>> np.hamming(12)
3411 array([ 0.08 , 0.15302337, 0.34890909, 0.60546483, 0.84123594, # may vary
3412 0.98136677, 0.98136677, 0.84123594, 0.60546483, 0.34890909,
3413 0.15302337, 0.08 ])
3414
3415 Plot the window and the frequency response.

Callers 1

test_hammingMethod · 0.90

Calls 2

onesFunction · 0.90
arrayFunction · 0.50

Tested by 1

test_hammingMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…