fn
bartlett
→Tensorbartlett(M: int, sym: bool = True, dtype: DTypeLike = None, device: DeviceLike = None)Bartlett (triangular) window.
Generates a triangular taper that ramps linearly from 0 to 1 and back to 0 across the window length. Equivalent to the convolution of two boxcar windows, the Bartlett window provides the simplest non-trivial reduction of spectral leakage at the price of a wider main lobe.
Parameters
MintNumber of samples in the output window; must be
>= 0.symbool= TrueIf
True (default) generate a symmetric window suitable for
filter design. If False generate a periodic window
suitable for use with the DFT (the length- symmetric
form with the last sample dropped).dtypeDTypeLike= NoneDesired dtype of the output tensor; defaults to
float32.deviceDeviceLike= NoneTarget device for the output tensor.
Returns
Tensor1-D tensor of length M containing the window samples.
Notes
Sample formula:
where (symmetric) or (periodic). The main-lobe width is roughly (about twice that of the rectangular window) and the peak side-lobe attenuation is .
Examples
>>> from lucid.signal.windows import bartlett
>>> bartlett(5)
Tensor([0.0000, 0.5000, 1.0000, 0.5000, 0.0000])