fftfreq

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

Computes the discrete Fourier transform sample frequencies.

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, ..., -1] / (d*n)        # if n is even
f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (d*n)  # if n is odd
Parameters:
  • n (int) – window length.

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

  • dtype (Optional[dtype]) – output array data type. Must be a real-valued floating-point data type. If dtype is None, the output array data type must be the default real-valued floating-point data type. Default: None.

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

Returns:

out (array) – an array of shape (n,) containing the sample frequencies.

Notes

New in version 2022.12.

Changed in version 2023.12: Required the output array have the default real-valued floating-point data type.