latest (dev)
Copy
Latest development documentation · Updated 2026-10-08
tensorplay.signal.windows API
Functions 11
bartlett
functionFull reference ↗- tensorplay.signal.windows.bartlett(M: int, *, sym: bool = True, dtype: dtype | None = None, layout: Layout = tensorplay.strided, device: device | None = None, requires_grad: bool = False) Tensor[source]
Computes the Bartlett window.
The samples form a triangle:
The window is scaled so that its largest value is 1. The value 1 itself does not occur when
Mis even andsymis True.- Parameters:
M (int) – number of points of the returned window.
- Keyword Arguments:
sym (bool, optional) – if False, returns a periodic window, which is the usual choice for spectral analysis. If True, returns a symmetric window, which is the usual choice for filter design. Default: True.
dtype (
tensorplay.dtype, optional) – the desired data type of the returned tensor. Default: ifNone, uses the global default (seetensorplay.set_default_dtype()).layout (
tensorplay.Layout, optional) – the desired layout of the returned tensor. Default:tensorplay.strided.device (
tensorplay.device, optional) – the desired device of the returned tensor. Default: ifNone, uses the current default tensor device (seetensorplay.set_default_device()).requires_grad (bool, optional) – whether autograd should record operations on the returned tensor. Default:
False.
Examples:
>>> # Symmetric Bartlett window. >>> tensorplay.signal.windows.bartlett(10) tensor([0., 0.2222, 0.4444, 0.6667, 0.8889, 0.8889, 0.6667, 0.4444, 0.2222, 0.]) >>> # Periodic Bartlett window. >>> tensorplay.signal.windows.bartlett(10, sym=False) tensor([0., 0.2, 0.4, 0.6, 0.8, 1., 0.8, 0.6, 0.4, 0.2])
blackman
functionFull reference ↗- tensorplay.signal.windows.blackman(M: int, *, sym: bool = True, dtype: dtype | None = None, layout: Layout = tensorplay.strided, device: device | None = None, requires_grad: bool = False) Tensor[source]
Computes the Blackman window.
The samples are
The window is scaled so that its largest value is 1. The value 1 itself does not occur when
Mis even andsymis True.- Parameters:
M (int) – number of points of the returned window.
- Keyword Arguments:
sym (bool, optional) – if False, returns a periodic window, which is the usual choice for spectral analysis. If True, returns a symmetric window, which is the usual choice for filter design. Default: True.
dtype (
tensorplay.dtype, optional) – the desired data type of the returned tensor. Default: ifNone, uses the global default (seetensorplay.set_default_dtype()).layout (
tensorplay.Layout, optional) – the desired layout of the returned tensor. Default:tensorplay.strided.device (
tensorplay.device, optional) – the desired device of the returned tensor. Default: ifNone, uses the current default tensor device (seetensorplay.set_default_device()).requires_grad (bool, optional) – whether autograd should record operations on the returned tensor. Default:
False.
Examples:
>>> # Symmetric Blackman window. >>> tensorplay.signal.windows.blackman(5) tensor([-0., 0.34, 1., 0.34, -0.]) >>> # Periodic Blackman window. >>> tensorplay.signal.windows.blackman(5, sym=False) tensor([-0., 0.2008, 0.8492, 0.8492, 0.2008])
cosine
functionFull reference ↗- tensorplay.signal.windows.cosine(M: int, *, sym: bool = True, dtype: dtype | None = None, layout: Layout = tensorplay.strided, device: device | None = None, requires_grad: bool = False) Tensor[source]
Computes a window with a simple cosine waveform, also known as the sine window.
The samples follow
The 0.5 in the numerator shifts the sample positions by half a step, so the window starts and ends at non-zero values (for a symmetric window the first and last samples equal sin(pi / (2M))).
The window is scaled so that its largest value is 1. The value 1 itself does not occur when
Mis even andsymis True.- Parameters:
M (int) – number of points of the returned window.
- Keyword Arguments:
sym (bool, optional) – if False, returns a periodic window, which is the usual choice for spectral analysis. If True, returns a symmetric window, which is the usual choice for filter design. Default: True.
dtype (
tensorplay.dtype, optional) – the desired data type of the returned tensor. Default: ifNone, uses the global default (seetensorplay.set_default_dtype()).layout (
tensorplay.Layout, optional) – the desired layout of the returned tensor. Default:tensorplay.strided.device (
tensorplay.device, optional) – the desired device of the returned tensor. Default: ifNone, uses the current default tensor device (seetensorplay.set_default_device()).requires_grad (bool, optional) – whether autograd should record operations on the returned tensor. Default:
False.
Examples:
>>> # Symmetric cosine window. >>> tensorplay.signal.windows.cosine(10) tensor([0.1564, 0.454, 0.7071, 0.891, 0.9877, 0.9877, 0.891, 0.7071, 0.454, 0.1564]) >>> # Periodic cosine window. >>> tensorplay.signal.windows.cosine(10, sym=False) tensor([0.1423, 0.4154, 0.6549, 0.8413, 0.9595, 1., 0.9595, 0.8413, 0.6549, 0.4154])
exponential
functionFull reference ↗- tensorplay.signal.windows.exponential(M: int, *, center: float | None = None, tau: float = 1.0, sym: bool = True, dtype: dtype | None = None, layout: Layout = tensorplay.strided, device: device | None = None, requires_grad: bool = False) Tensor[source]
Computes a window with an exponentially decaying waveform, also known as the Poisson window.
The samples decay exponentially with the distance from the window center:
where c is the
centerof the window.The window is scaled so that its largest value is 1. The value 1 itself does not occur when
Mis even andsymis True.- Parameters:
M (int) – number of points of the returned window.
- Keyword Arguments:
center (float, optional) – location of the window center. Default: M / 2 if sym is False, else (M - 1) / 2.
tau (float, optional) – decay parameter, conceptually a percentage in (0, 100]. With tau = 100 the window degenerates to a constant. Default: 1.0.
sym (bool, optional) – if False, returns a periodic window, which is the usual choice for spectral analysis. If True, returns a symmetric window, which is the usual choice for filter design. Default: True.
dtype (
tensorplay.dtype, optional) – the desired data type of the returned tensor. Default: ifNone, uses the global default (seetensorplay.set_default_dtype()).layout (
tensorplay.Layout, optional) – the desired layout of the returned tensor. Default:tensorplay.strided.device (
tensorplay.device, optional) – the desired device of the returned tensor. Default: ifNone, uses the current default tensor device (seetensorplay.set_default_device()).requires_grad (bool, optional) – whether autograd should record operations on the returned tensor. Default:
False.
Examples:
>>> # Symmetric exponential window of length 10 with decay 1.0. >>> # The center is (M - 1) / 2 with M = 10. >>> tensorplay.signal.windows.exponential(10) tensor([0.0111, 0.0302, 0.0821, 0.2231, 0.6065, 0.6065, 0.2231, 0.0821, 0.0302, 0.0111]) >>> # Periodic exponential window of length 10 with decay 0.5. >>> tensorplay.signal.windows.exponential(10, sym=False, tau=0.5) tensor([0., 0.0003, 0.0025, 0.0183, 0.1353, 1., 0.1353, 0.0183, 0.0025, 0.0003])
gaussian
functionFull reference ↗- tensorplay.signal.windows.gaussian(M: int, *, std: float = 1.0, sym: bool = True, dtype: dtype | None = None, layout: Layout = tensorplay.strided, device: device | None = None, requires_grad: bool = False) Tensor[source]
Computes a window with a Gaussian waveform.
The samples follow a Gaussian bump centered in the window:
The window is scaled so that its largest value is 1. The value 1 itself does not occur when
Mis even andsymis True.- Parameters:
M (int) – number of points of the returned window.
- Keyword Arguments:
std (float, optional) – standard deviation of the Gaussian; it controls how narrow or wide the window is. Default: 1.0.
sym (bool, optional) – if False, returns a periodic window, which is the usual choice for spectral analysis. If True, returns a symmetric window, which is the usual choice for filter design. Default: True.
dtype (
tensorplay.dtype, optional) – the desired data type of the returned tensor. Default: ifNone, uses the global default (seetensorplay.set_default_dtype()).layout (
tensorplay.Layout, optional) – the desired layout of the returned tensor. Default:tensorplay.strided.device (
tensorplay.device, optional) – the desired device of the returned tensor. Default: ifNone, uses the current default tensor device (seetensorplay.set_default_device()).requires_grad (bool, optional) – whether autograd should record operations on the returned tensor. Default:
False.
Examples:
>>> # Symmetric Gaussian window of length 10 with std 1.0. >>> tensorplay.signal.windows.gaussian(10) tensor([0., 0.0022, 0.0439, 0.3247, 0.8825, 0.8825, 0.3247, 0.0439, 0.0022, 0.]) >>> # Periodic Gaussian window of length 10 with std 0.9. >>> tensorplay.signal.windows.gaussian(10, sym=False, std=0.9) tensor([0., 0.0001, 0.0039, 0.0847, 0.5394, 1., 0.5394, 0.0847, 0.0039, 0.0001])
general_cosine
functionFull reference ↗- tensorplay.signal.windows.general_cosine(M, *, a: Iterable, sym: bool = True, dtype: dtype | None = None, layout: Layout = tensorplay.strided, device: device | None = None, requires_grad: bool = False) Tensor[source]
Computes the general cosine window, a weighted sum of cosines whose frequencies are integer multiples of the fundamental.
The samples are
The window is scaled so that its largest value is 1. The value 1 itself does not occur when
Mis even andsymis True.- Parameters:
M (int) – number of points of the returned window.
- Keyword Arguments:
a (Iterable) – coefficient of each cosine term.
sym (bool, optional) – if False, returns a periodic window, which is the usual choice for spectral analysis. If True, returns a symmetric window, which is the usual choice for filter design. Default: True.
dtype (
tensorplay.dtype, optional) – the desired data type of the returned tensor. Default: ifNone, uses the global default (seetensorplay.set_default_dtype()).layout (
tensorplay.Layout, optional) – the desired layout of the returned tensor. Default:tensorplay.strided.device (
tensorplay.device, optional) – the desired device of the returned tensor. Default: ifNone, uses the current default tensor device (seetensorplay.set_default_device()).requires_grad (bool, optional) – whether autograd should record operations on the returned tensor. Default:
False.
Examples:
>>> # Symmetric general cosine window with 3 coefficients. >>> tensorplay.signal.windows.general_cosine(10, a=[0.46, 0.23, 0.31], sym=True) tensor([0.54, 0.3376, 0.1288, 0.42, 0.9136, 0.9136, 0.42, 0.1288, 0.3376, 0.54]) >>> # Periodic general cosine window with 2 coefficients. >>> tensorplay.signal.windows.general_cosine(10, a=[0.5, 1 - 0.5], sym=False) tensor([0., 0.0955, 0.3455, 0.6545, 0.9045, 1., 0.9045, 0.6545, 0.3455, 0.0955])
general_hamming
functionFull reference ↗- tensorplay.signal.windows.general_hamming(M, *, alpha: float = 0.54, sym: bool = True, dtype: dtype | None = None, layout: Layout = tensorplay.strided, device: device | None = None, requires_grad: bool = False) Tensor[source]
Computes the general Hamming window, the two-term member of the general cosine family.
The samples are
The window is scaled so that its largest value is 1. The value 1 itself does not occur when
Mis even andsymis True.- Parameters:
M (int) – number of points of the returned window.
- Keyword Arguments:
alpha (float, optional) – the window coefficient. Default: 0.54.
sym (bool, optional) – if False, returns a periodic window, which is the usual choice for spectral analysis. If True, returns a symmetric window, which is the usual choice for filter design. Default: True.
dtype (
tensorplay.dtype, optional) – the desired data type of the returned tensor. Default: ifNone, uses the global default (seetensorplay.set_default_dtype()).layout (
tensorplay.Layout, optional) – the desired layout of the returned tensor. Default:tensorplay.strided.device (
tensorplay.device, optional) – the desired device of the returned tensor. Default: ifNone, uses the current default tensor device (seetensorplay.set_default_device()).requires_grad (bool, optional) – whether autograd should record operations on the returned tensor. Default:
False.
Examples:
>>> # Symmetric Hamming window via the general Hamming builder. >>> tensorplay.signal.windows.general_hamming(10, sym=True) tensor([0.08, 0.1876, 0.4601, 0.77, 0.9723, 0.9723, 0.77, 0.4601, 0.1876, 0.08]) >>> # Periodic Hann window via the general Hamming builder. >>> tensorplay.signal.windows.general_hamming(10, alpha=0.5, sym=False) tensor([0., 0.0955, 0.3455, 0.6545, 0.9045, 1., 0.9045, 0.6545, 0.3455, 0.0955])
hamming
functionFull reference ↗- tensorplay.signal.windows.hamming(M: int, *, sym: bool = True, dtype: dtype | None = None, layout: Layout = tensorplay.strided, device: device | None = None, requires_grad: bool = False) Tensor[source]
Computes the Hamming window.
The samples are
with and .
The window is scaled so that its largest value is 1. The value 1 itself does not occur when
Mis even andsymis True.- Parameters:
M (int) – number of points of the returned window.
- Keyword Arguments:
sym (bool, optional) – if False, returns a periodic window, which is the usual choice for spectral analysis. If True, returns a symmetric window, which is the usual choice for filter design. Default: True.
dtype (
tensorplay.dtype, optional) – the desired data type of the returned tensor. Default: ifNone, uses the global default (seetensorplay.set_default_dtype()).layout (
tensorplay.Layout, optional) – the desired layout of the returned tensor. Default:tensorplay.strided.device (
tensorplay.device, optional) – the desired device of the returned tensor. Default: ifNone, uses the current default tensor device (seetensorplay.set_default_device()).requires_grad (bool, optional) – whether autograd should record operations on the returned tensor. Default:
False.
Examples:
>>> # Symmetric Hamming window. >>> tensorplay.signal.windows.hamming(10) tensor([0.08, 0.1876, 0.4601, 0.77, 0.9723, 0.9723, 0.77, 0.4601, 0.1876, 0.08]) >>> # Periodic Hamming window. >>> tensorplay.signal.windows.hamming(10, sym=False) tensor([0.08, 0.1679, 0.3979, 0.6821, 0.9121, 1., 0.9121, 0.6821, 0.3979, 0.1679])
hann
functionFull reference ↗- tensorplay.signal.windows.hann(M: int, *, sym: bool = True, dtype: dtype | None = None, layout: Layout = tensorplay.strided, device: device | None = None, requires_grad: bool = False) Tensor[source]
Computes the Hann window.
The samples are
The window is scaled so that its largest value is 1. The value 1 itself does not occur when
Mis even andsymis True.- Parameters:
M (int) – number of points of the returned window.
- Keyword Arguments:
sym (bool, optional) – if False, returns a periodic window, which is the usual choice for spectral analysis. If True, returns a symmetric window, which is the usual choice for filter design. Default: True.
dtype (
tensorplay.dtype, optional) – the desired data type of the returned tensor. Default: ifNone, uses the global default (seetensorplay.set_default_dtype()).layout (
tensorplay.Layout, optional) – the desired layout of the returned tensor. Default:tensorplay.strided.device (
tensorplay.device, optional) – the desired device of the returned tensor. Default: ifNone, uses the current default tensor device (seetensorplay.set_default_device()).requires_grad (bool, optional) – whether autograd should record operations on the returned tensor. Default:
False.
Examples:
>>> # Symmetric Hann window. >>> tensorplay.signal.windows.hann(10) tensor([0., 0.117, 0.4132, 0.75, 0.9698, 0.9698, 0.75, 0.4132, 0.117, 0.]) >>> # Periodic Hann window. >>> tensorplay.signal.windows.hann(10, sym=False) tensor([0., 0.0955, 0.3455, 0.6545, 0.9045, 1., 0.9045, 0.6545, 0.3455, 0.0955])
kaiser
functionFull reference ↗- tensorplay.signal.windows.kaiser(M: int, *, beta: float = 12.0, sym: bool = True, dtype: dtype | None = None, layout: Layout = tensorplay.strided, device: device | None = None, requires_grad: bool = False) Tensor[source]
Computes the Kaiser window.
The samples are
where is the modified Bessel function of the first kind of order zero, evaluated with
tensorplay.i0(), and for a symmetric window, otherwise .The window is scaled so that its largest value is 1. The value 1 itself does not occur when
Mis even andsymis True.- Parameters:
M (int) – number of points of the returned window.
- Keyword Arguments:
beta (float, optional) – shape parameter of the window. Must be non-negative. Default: 12.0
sym (bool, optional) – if False, returns a periodic window, which is the usual choice for spectral analysis. If True, returns a symmetric window, which is the usual choice for filter design. Default: True.
dtype (
tensorplay.dtype, optional) – the desired data type of the returned tensor. Default: ifNone, uses the global default (seetensorplay.set_default_dtype()).layout (
tensorplay.Layout, optional) – the desired layout of the returned tensor. Default:tensorplay.strided.device (
tensorplay.device, optional) – the desired device of the returned tensor. Default: ifNone, uses the current default tensor device (seetensorplay.set_default_device()).requires_grad (bool, optional) – whether autograd should record operations on the returned tensor. Default:
False.
Examples:
>>> # Symmetric Kaiser window of length 5 with shape parameter 12.0. >>> tensorplay.signal.windows.kaiser(5) tensor([0.0001, 0.2157, 1., 0.2157, 0.0001]) >>> # Periodic Kaiser window of length 5 with shape parameter 0.9. >>> tensorplay.signal.windows.kaiser(5, sym=False, beta=0.9) tensor([0.8244, 0.9348, 0.9926, 0.9926, 0.9348])
nuttall
functionFull reference ↗- tensorplay.signal.windows.nuttall(M: int, *, sym: bool = True, dtype: dtype | None = None, layout: Layout = tensorplay.strided, device: device | None = None, requires_grad: bool = False) Tensor[source]
Computes the minimum 4-term Blackman-Harris window described by Nuttall.
The window is a general cosine sum with the Nuttall coefficients , , , :
where for a symmetric window and for a periodic one.
The window is scaled so that its largest value is 1. The value 1 itself does not occur when
Mis even andsymis True.- Parameters:
M (int) – number of points of the returned window.
- Keyword Arguments:
sym (bool, optional) – if False, returns a periodic window, which is the usual choice for spectral analysis. If True, returns a symmetric window, which is the usual choice for filter design. Default: True.
dtype (
tensorplay.dtype, optional) – the desired data type of the returned tensor. Default: ifNone, uses the global default (seetensorplay.set_default_dtype()).layout (
tensorplay.Layout, optional) – the desired layout of the returned tensor. Default:tensorplay.strided.device (
tensorplay.device, optional) – the desired device of the returned tensor. Default: ifNone, uses the current default tensor device (seetensorplay.set_default_device()).requires_grad (bool, optional) – whether autograd should record operations on the returned tensor. Default:
False.
References:
- A. Nuttall, "Some windows with very good sidelobe behavior," IEEE Transactions on Acoustics, Speech, and Signal Processing, vol. 29, no. 1, pp. 84-91, Feb 1981. https://doi.org/10.1109/TASSP.1981.1163506 - Heinzel G. et al., "Spectrum and spectral density estimation by the Discrete Fourier transform (DFT), including a comprehensive list of window functions and some new flat-top windows", February 15, 2002 https://holometer.fnal.gov/GH_FFT.pdfExamples:
>>> # Symmetric Nuttall window. >>> tensorplay.signal.windows.nuttall(5) tensor([0.0004, 0.227, 1., 0.227, 0.0004]) >>> # Periodic Nuttall window. >>> tensorplay.signal.windows.nuttall(5, sym=False) tensor([0.0004, 0.1105, 0.7983, 0.7983, 0.1105])
Help improve this page
Found an error, an unclear step, or a missing example?

