rfftfreq

rfftfreq(n: int, /, *, d: float = 1.0, device: device | None = None) array

Computes the discrete Fourier transform sample frequencies (for rfft and irfft).

For a Fourier transform of length n and length unit of d, the frequencies are described as:

f = [0, 1, ...,     n/2-1,     n/2] / (d*n)  # if n is even
f = [0, 1, ..., (n-1)/2-1, (n-1)/2] / (d*n)  # if n is odd

The Nyquist frequency component is considered to be positive.

Parameters:
  • n (int) – window length.

  • d (float) – sample spacing between individual samples of the Fourier transform input. Default: 1.0.

  • device (Optional[device]) – device on which to place the created array. Default: None.

Returns:

out (array) – an array of shape (n//2+1,) containing the sample frequencies. The returned array must have the default real-valued floating-point data type.

Notes

New in version 2022.12.