fn

hamming

Tensor
hamming(M: int, sym: bool = True, dtype: DTypeLike = None, device: DeviceLike = None)
source

Hamming window.

The Hamming window is a raised cosine on a nonzero pedestal, chosen so that the first side-lobe is suppressed about 43dB-43\, \text{dB} — substantially better than the Hann window at the cost of slower asymptotic side-lobe decay (only 6dB/octave-6\, \text{dB/octave}).

Parameters

Mint
Number of samples in the output window; must be >= 0.
symbool= True
Symmetric (True, default) or periodic (False) variant.
dtypeDTypeLike= None
Desired dtype of the output tensor.
deviceDeviceLike= None
Target device for the output tensor.

Returns

Tensor

1-D tensor of length M containing the window samples.

Notes

Special case of general_hamming with α=0.54\alpha = 0.54:

w[n]=0.540.46cos ⁣(2πnN1),0n<N.w[n] = 0.54 - 0.46 \cos\!\left(\frac{2\pi n}{N - 1}\right), \qquad 0 \le n < N.

Main-lobe width 8π/N8\pi/N. Endpoint values are 0.08 rather than 0.

Examples

>>> from lucid.signal.windows import hamming
>>> hamming(5)
Tensor([0.0800, 0.5400, 1.0000, 0.5400, 0.0800])