View Source NxSignal.Windows (NxSignal v0.3.0)

Common window functions.

Link to this section Summary

Functions: Windowing

Bartlett triangular window.

Blackman window.

Hamming window.

Hann window.

Creates a Kaiser window of size window_length.

Rectangular window.

Triangular window.

Link to this section Functions: Windowing

Bartlett triangular window.

See also: triangular/1

options

Options

  • :type - the output type for the window. Defaults to {:f, 32}
  • :name - the axis name. Defaults to nil

examples

Examples

iex> NxSignal.Windows.bartlett(3)
#Nx.Tensor<
  f32[3]
  [0.0, 0.6666667, 0.6666666]
>

Blackman window.

options

Options

  • :is_periodic - If true, produces a periodic window, otherwise produces a symmetric window. Defaults to true
  • :type - the output type for the window. Defaults to {:f, 32}
  • :name - the axis name. Defaults to nil

examples

Examples

iex> NxSignal.Windows.blackman(5, is_periodic: false)
#Nx.Tensor<
  f32[5]
  [-1.4901161e-8, 0.34000003, 0.99999994, 0.34000003, -1.4901161e-8]
>

iex> NxSignal.Windows.blackman(5, is_periodic: true)
#Nx.Tensor<
  f32[5]
  [-1.4901161e-8, 0.20077012, 0.84922993, 0.84922993, 0.20077012]
>

iex> NxSignal.Windows.blackman(6, is_periodic: true, type: {:f, 32})
#Nx.Tensor<
  f32[6]
  [-1.4901161e-8, 0.13, 0.63, 0.99999994, 0.63, 0.13]
>

Hamming window.

options

Options

  • :is_periodic - If true, produces a periodic window, otherwise produces a symmetric window. Defaults to true
  • :type - the output type for the window. Defaults to {:f, 32}
  • :name - the axis name. Defaults to nil

examples

Examples

iex> NxSignal.Windows.hamming(5, is_periodic: true)
#Nx.Tensor<
  f32[5]
  [0.08000001, 0.3978522, 0.9121479, 0.9121478, 0.39785212]
>
iex> NxSignal.Windows.hamming(5, is_periodic: false)
#Nx.Tensor<
  f32[5]
  [0.08000001, 0.54, 1.0, 0.54, 0.08000001]
>

Hann window.

options

Options

  • :is_periodic - If true, produces a periodic window, otherwise produces a symmetric window. Defaults to true
  • :type - the output type for the window. Defaults to {:f, 32}
  • :name - the axis name. Defaults to nil

examples

Examples

iex> NxSignal.Windows.hann(5, is_periodic: false)
#Nx.Tensor<
  f32[5]
  [0.0, 0.5, 1.0, 0.5, 0.0]
>
iex> NxSignal.Windows.hann(5, is_periodic: true)
#Nx.Tensor<
  f32[5]
  [0.0, 0.34549153, 0.90450853, 0.9045085, 0.34549144]
>

Creates a Kaiser window of size window_length.

The Kaiser window is a taper formed by using a Bessel function.

options

Options

  • :is_periodic - If true, produces a periodic window, otherwise produces a symmetric window. Defaults to true
  • :type - the output type for the window. Defaults to {:f, 32}
  • :beta - Shape parameter for the window. As beta increases, the window becomes more focused in frequency domain. Defaults to 12.0.
  • :eps - Epsilon value to avoid division by zero. Defaults to 1.0e-7.
  • :axis_name - the axis name. Defaults to nil

examples

Examples

iex> NxSignal.Windows.kaiser(4, beta: 12.0, is_periodic: true)
#Nx.Tensor<
  f32[4]
  [5.277619e-5, 0.21566667, 1.0, 0.21566667]
>

iex> NxSignal.Windows.kaiser(5, beta: 12.0, is_periodic: true)
#Nx.Tensor<
  f32[5]
  [5.277619e-5, 0.10171464, 0.792937, 0.792937, 0.10171464]
>

iex> NxSignal.Windows.kaiser(4, beta: 12.0, is_periodic: false)
#Nx.Tensor<
  f32[4]
  [5.277619e-5, 0.5188395, 0.51883906, 5.277619e-5]
>
Link to this function

rectangular(n, opts \\ [])

View Source

Rectangular window.

Useful for when no window function should be applied.

options

Options

  • :type - the output type. Defaults to s64

examples

Examples

iex> NxSignal.Windows.rectangular(5)
#Nx.Tensor<
  s64[5]
  [1, 1, 1, 1, 1]
>

iex> NxSignal.Windows.rectangular(5, type: :f32)
#Nx.Tensor<
  f32[5]
  [1.0, 1.0, 1.0, 1.0, 1.0]
>
Link to this function

triangular(n, opts \\ [])

View Source

Triangular window.

See also: bartlett/1

options

Options

  • :n - The window length. Mandatory option.
  • :type - the output type for the window. Defaults to {:f, 32}
  • :name - the axis name. Defaults to nil

examples

Examples

iex> NxSignal.Windows.triangular(3)
#Nx.Tensor<
  f32[3]
  [0.5, 1.0, 0.5]
>