# tensorplay.signal.windows API Source: https://www.tensorplay.cn/docs/api/tensorplay.signal.windows.html ## Functions 11 [#](#api-tensorplay.signal.windows.bartlett) ### bartlett function[Full reference ↗](/docs/generated/tensorplay.signal.windows.bartlett.html) ```python 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 ``` Computes the Bartlett window. The samples form a triangle: $$\begin{split}w_n = 1 - \left| \frac{2n}{M - 1} - 1 \right| = \begin{cases} \frac{2n}{M - 1} & \text{if } 0 \leq n \leq \frac{M - 1}{2} \\ 2 - \frac{2n}{M - 1} & \text{if } \frac{M - 1}{2} < n < M \\ \end{cases}\end{split}$$ The window is scaled so that its largest value is 1. The value 1 itself does not occur when M is even and sym is True. Parameters: M ([int](https://docs.python.org/3/builtins/functions.html#int)) – number of points of the returned window. Keyword Arguments: - sym ([bool](https://docs.python.org/3/builtins/functions.html#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](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of the returned tensor. Default: if None, uses the global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout ([tensorplay.Layout](/docs/generated/tensorplay.Layout.html#tensorplay.Layout), optional) – the desired layout of the returned tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of the returned tensor. Default: if None, uses the current default tensor device (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#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]) ``` [#](#api-tensorplay.signal.windows.blackman) ### blackman function[Full reference ↗](/docs/generated/tensorplay.signal.windows.blackman.html) ```python 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 ``` Computes the Blackman window. The samples are $$w_n = 0.42 - 0.5 \cos \left( \frac{2 \pi n}{M - 1} \right) + 0.08 \cos \left( \frac{4 \pi n}{M - 1} \right)$$ The window is scaled so that its largest value is 1. The value 1 itself does not occur when M is even and sym is True. Parameters: M ([int](https://docs.python.org/3/builtins/functions.html#int)) – number of points of the returned window. Keyword Arguments: - sym ([bool](https://docs.python.org/3/builtins/functions.html#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](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of the returned tensor. Default: if None, uses the global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout ([tensorplay.Layout](/docs/generated/tensorplay.Layout.html#tensorplay.Layout), optional) – the desired layout of the returned tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of the returned tensor. Default: if None, uses the current default tensor device (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#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]) ``` [#](#api-tensorplay.signal.windows.cosine) ### cosine function[Full reference ↗](/docs/generated/tensorplay.signal.windows.cosine.html) ```python 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 ``` Computes a window with a simple cosine waveform, also known as the sine window. The samples follow $$w_n = \sin\left(\frac{\pi (n + 0.5)}{M}\right)$$ 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 M is even and sym is True. Parameters: M ([int](https://docs.python.org/3/builtins/functions.html#int)) – number of points of the returned window. Keyword Arguments: - sym ([bool](https://docs.python.org/3/builtins/functions.html#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](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of the returned tensor. Default: if None, uses the global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout ([tensorplay.Layout](/docs/generated/tensorplay.Layout.html#tensorplay.Layout), optional) – the desired layout of the returned tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of the returned tensor. Default: if None, uses the current default tensor device (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#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]) ``` [#](#api-tensorplay.signal.windows.exponential) ### exponential function[Full reference ↗](/docs/generated/tensorplay.signal.windows.exponential.html) ```python 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 ``` 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: $$w_n = \exp{\left(-\frac{|n - c|}{\tau}\right)}$$ where c is the center of the window. The window is scaled so that its largest value is 1. The value 1 itself does not occur when M is even and sym is True. Parameters: M ([int](https://docs.python.org/3/builtins/functions.html#int)) – number of points of the returned window. Keyword Arguments: - center ([float](https://docs.python.org/3/builtins/functions.html#float), optional) – location of the window center. Default: M / 2 if sym is False, else (M - 1) / 2. - tau ([float](https://docs.python.org/3/builtins/functions.html#float), optional) – decay parameter, conceptually a percentage in (0, 100]. With tau = 100 the window degenerates to a constant. Default: 1.0. - sym ([bool](https://docs.python.org/3/builtins/functions.html#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](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of the returned tensor. Default: if None, uses the global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout ([tensorplay.Layout](/docs/generated/tensorplay.Layout.html#tensorplay.Layout), optional) – the desired layout of the returned tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of the returned tensor. Default: if None, uses the current default tensor device (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#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]) ``` [#](#api-tensorplay.signal.windows.gaussian) ### gaussian function[Full reference ↗](/docs/generated/tensorplay.signal.windows.gaussian.html) ```python 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 ``` Computes a window with a Gaussian waveform. The samples follow a Gaussian bump centered in the window: $$w_n = \exp{\left(-\left(\frac{n}{2\sigma}\right)^2\right)}$$ The window is scaled so that its largest value is 1. The value 1 itself does not occur when M is even and sym is True. Parameters: M ([int](https://docs.python.org/3/builtins/functions.html#int)) – number of points of the returned window. Keyword Arguments: - std ([float](https://docs.python.org/3/builtins/functions.html#float), optional) – standard deviation of the Gaussian; it controls how narrow or wide the window is. Default: 1.0. - sym ([bool](https://docs.python.org/3/builtins/functions.html#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](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of the returned tensor. Default: if None, uses the global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout ([tensorplay.Layout](/docs/generated/tensorplay.Layout.html#tensorplay.Layout), optional) – the desired layout of the returned tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of the returned tensor. Default: if None, uses the current default tensor device (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#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]) ``` [#](#api-tensorplay.signal.windows.general_cosine) ### general_cosine function[Full reference ↗](/docs/generated/tensorplay.signal.windows.general_cosine.html) ```python 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 ``` Computes the general cosine window, a weighted sum of cosines whose frequencies are integer multiples of the fundamental. The samples are $$w_n = \sum^{M-1}_{i=0} (-1)^i a_i \cos{ \left( \frac{2 \pi i n}{M - 1}\right)}$$ The window is scaled so that its largest value is 1. The value 1 itself does not occur when M is even and sym is True. Parameters: M ([int](https://docs.python.org/3/builtins/functions.html#int)) – number of points of the returned window. Keyword Arguments: - a (Iterable) – coefficient of each cosine term. - sym ([bool](https://docs.python.org/3/builtins/functions.html#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](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of the returned tensor. Default: if None, uses the global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout ([tensorplay.Layout](/docs/generated/tensorplay.Layout.html#tensorplay.Layout), optional) – the desired layout of the returned tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of the returned tensor. Default: if None, uses the current default tensor device (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#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]) ``` [#](#api-tensorplay.signal.windows.general_hamming) ### general_hamming function[Full reference ↗](/docs/generated/tensorplay.signal.windows.general_hamming.html) ```python 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 ``` Computes the general Hamming window, the two-term member of the general cosine family. The samples are $$w_n = \alpha - (1 - \alpha) \cos{ \left( \frac{2 \pi n}{M-1} \right)}$$ The window is scaled so that its largest value is 1. The value 1 itself does not occur when M is even and sym is True. Parameters: M ([int](https://docs.python.org/3/builtins/functions.html#int)) – number of points of the returned window. Keyword Arguments: - alpha ([float](https://docs.python.org/3/builtins/functions.html#float), optional) – the window coefficient. Default: 0.54. - sym ([bool](https://docs.python.org/3/builtins/functions.html#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](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of the returned tensor. Default: if None, uses the global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout ([tensorplay.Layout](/docs/generated/tensorplay.Layout.html#tensorplay.Layout), optional) – the desired layout of the returned tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of the returned tensor. Default: if None, uses the current default tensor device (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#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]) ``` [#](#api-tensorplay.signal.windows.hamming) ### hamming function[Full reference ↗](/docs/generated/tensorplay.signal.windows.hamming.html) ```python 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 ``` Computes the Hamming window. The samples are $$w_n = \alpha - \beta\ \cos \left( \frac{2 \pi n}{M - 1} \right)$$ with $\alpha = 0.54$ and $\beta = 0.46$. The window is scaled so that its largest value is 1. The value 1 itself does not occur when M is even and sym is True. Parameters: M ([int](https://docs.python.org/3/builtins/functions.html#int)) – number of points of the returned window. Keyword Arguments: - sym ([bool](https://docs.python.org/3/builtins/functions.html#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](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of the returned tensor. Default: if None, uses the global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout ([tensorplay.Layout](/docs/generated/tensorplay.Layout.html#tensorplay.Layout), optional) – the desired layout of the returned tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of the returned tensor. Default: if None, uses the current default tensor device (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#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]) ``` [#](#api-tensorplay.signal.windows.hann) ### hann function[Full reference ↗](/docs/generated/tensorplay.signal.windows.hann.html) ```python 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 ``` Computes the Hann window. The samples are $$w_n = \frac{1}{2}\ \left[1 - \cos \left( \frac{2 \pi n}{M - 1} \right)\right] = \sin^2 \left( \frac{\pi n}{M - 1} \right)$$ The window is scaled so that its largest value is 1. The value 1 itself does not occur when M is even and sym is True. Parameters: M ([int](https://docs.python.org/3/builtins/functions.html#int)) – number of points of the returned window. Keyword Arguments: - sym ([bool](https://docs.python.org/3/builtins/functions.html#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](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of the returned tensor. Default: if None, uses the global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout ([tensorplay.Layout](/docs/generated/tensorplay.Layout.html#tensorplay.Layout), optional) – the desired layout of the returned tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of the returned tensor. Default: if None, uses the current default tensor device (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#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]) ``` [#](#api-tensorplay.signal.windows.kaiser) ### kaiser function[Full reference ↗](/docs/generated/tensorplay.signal.windows.kaiser.html) ```python 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 ``` Computes the Kaiser window. The samples are $$w_n = I_0 \left( \beta \sqrt{1 - \left( {\frac{n - N/2}{N/2}} \right) ^2 } \right) / I_0( \beta )$$ where $I_0$ is the modified Bessel function of the first kind of order zero, evaluated with tensorplay.i0(), and $N = M - 1$ for a symmetric window, otherwise $N = M$. The window is scaled so that its largest value is 1. The value 1 itself does not occur when M is even and sym is True. Parameters: M ([int](https://docs.python.org/3/builtins/functions.html#int)) – number of points of the returned window. Keyword Arguments: - beta ([float](https://docs.python.org/3/builtins/functions.html#float), optional) – shape parameter of the window. Must be non-negative. Default: 12.0 - sym ([bool](https://docs.python.org/3/builtins/functions.html#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](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of the returned tensor. Default: if None, uses the global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout ([tensorplay.Layout](/docs/generated/tensorplay.Layout.html#tensorplay.Layout), optional) – the desired layout of the returned tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of the returned tensor. Default: if None, uses the current default tensor device (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#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]) ``` [#](#api-tensorplay.signal.windows.nuttall) ### nuttall function[Full reference ↗](/docs/generated/tensorplay.signal.windows.nuttall.html) ```python 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 ``` Computes the minimum 4-term Blackman-Harris window described by Nuttall. The window is a general cosine sum with the Nuttall coefficients $a_0 = 0.3635819$, $a_1 = 0.4891775$, $a_2 = 0.1365995$, $a_3 = 0.0106411$: $$w_n = a_0 - a_1 \cos{(z_n)} + a_2 \cos{(2z_n)} - a_3 \cos{(3z_n)}$$ where $z_n = \frac{2 \pi n}{M - 1}$ for a symmetric window and $z_n = \frac{2 \pi n}{M}$ for a periodic one. The window is scaled so that its largest value is 1. The value 1 itself does not occur when M is even and sym is True. Parameters: M ([int](https://docs.python.org/3/builtins/functions.html#int)) – number of points of the returned window. Keyword Arguments: - sym ([bool](https://docs.python.org/3/builtins/functions.html#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](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of the returned tensor. Default: if None, uses the global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout ([tensorplay.Layout](/docs/generated/tensorplay.Layout.html#tensorplay.Layout), optional) – the desired layout of the returned tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of the returned tensor. Default: if None, uses the current default tensor device (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#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.pdf ``` Examples: ``` >>> # 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]) ```