mindspore.ops.bartlett_window

mindspore.ops.bartlett_window(window_length, periodic=True, *, dtype=None)[源代码]

巴特利特窗口函数。

是一种三角形状的加权函数,通常用于平滑处理或频域分析信号。

\[\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}\]

其中, \(N\) 是总的窗口长度 window_length ,n为小于 \(N\) 的自然数 [0, 1, …, N-1]。

参数:
  • window_length (Tensor) - 窗口的大小。

  • periodic (bool,可选) - 如果为 True ,表示返回周期窗口。如果为 False ,表示返回对称窗口。默认 True

关键字参数:
  • dtype (mindspore.dtype,可选) - 指定数据类型。默认 None

返回:

一维tensor。

支持平台:

Ascend GPU CPU

样例:

>>> 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. ]