- paddle.fft. fftfreq ( n, d=1.0, dtype=None, name=None )
Return the Discrete Fourier Transform sample frequencies.
The returned float array f contains the frequency bin centers in cycles per unit of the sample spacing (with zero at the start). For instance, if the sample spacing is in seconds, then the frequency unit is cycles/second.
Given input length n and a sample spacing d:
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
n (int) – Dimension inputed.
d (scalar, optional) – Sample spacing (inverse of the sampling rate). Defaults is 1.
name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.
Tensor. A tensor of length ‘n’ containing the sampling frequency.
import numpy as np import paddle x = np.array([3, 1, 2, 2, 3], dtype=float) scalar_temp = 0.5 n = x.size fftfreq_xp = paddle.fft.fftfreq(n, d=scalar_temp) print(fftfreq_xp) # Tensor(shape=, dtype=float32, place=CUDAPlace(0), stop_gradient=True, # [ 0. , 0.40000001, 0.80000001, -0.80000001, -0.40000001])