mindspore.ops.bartlett_window
- mindspore.ops.bartlett_window(window_length, periodic=True, *, dtype=None)[source]
Bartlett window function.
A triangular-shaped weighting function used for smoothing or frequency analysis of signals in digital signal processing.
\[\begin{split}w[n] = 1 - \left| \frac{2n}{N-1} - 1 \right| = \begin{cases} \frac{2n}{N - 1} & \text{if } 0 \leq n \leq \frac{N - 1}{2} \\ 2 - \frac{2n}{N - 1} & \text{if } \frac{N - 1}{2} < n < N \\ \end{cases},\end{split}\]where \(N\) is the full window size, and n is natural number less than \(N\) :[0, 1, …, N-1].
- Parameters
- Keyword Arguments
dtype (mindspore.dtype, optional) – The data type specified. Default
None
.- Returns
A 1-D tensor.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> window_length = mindspore.tensor(5) >>> output = mindspore.ops.bartlett_window(window_length) >>> print(output) [0. 0.4 0.8 0.8 0.4] >>> output = mindspore.ops.bartlett_window(window_length, periodic=False) >>> print(output) [0. 0.5 1. 0.5 0. ]