# Fast Fourier transformation of discrete linear line function in Python using scipy.fft [closed]

Consider a time series dataset generated by a linear function

$$y = a \cdot n, \; n=0,1,...,N$$

According to this reference (entry 308 in the table for one-dimensional functions), the analytical solution of Fourier transformation is given by:

$$f(\xi) = a\left(\frac{i}{2 \pi}\right) \delta^{'}(\xi)$$ where $$\delta^{'}$$ is the first distribution derivative of the Dirac delta function. So the amplitude of frequencies other than zero should be zero, i.e.:

$$f(\xi)=0, \forall \xi \ne 0$$

However, using scipy.fft in Python, the result is different: the amplitude for frequencies greater than zero is not zero. What could be the reason for the difference?


from scipy.fft import fft, fftfreq
def my_fft(x):

deltaT = 1
# Number of sample points
N = len(x)
xf = fftfreq(N, deltaT)[:N//2]
yf = fft(x)
ampl = 1/(N/2) * np.abs(yf[0:N//2])

plt.figure(figsize=(4, 3), dpi=300)
for i in range(len(xf)):
plt.vlines(x=xf[i], ymin=0, ymax=ampl[i])
# plt.plot(key_list[i], value_list[i])
plt.ylabel('Amplitude')
plt.xlabel(r'Frequency ($$\times 2\pi$$)')
plt.xlim([-0.01, 0.51])
plt.grid(axis='y')
plt.show()

def run():
a = 2
n = 100
x = np.ones(n)
for i in range(n):
x[i] = a*i
my_fft(x)

run()


• Entry 308 refers to $x^n$ not $x \cdot n$. Closing until you clarify. Plus, all of those entries in the table are for the continuous-time Fourier transform, not the discrete Fourier transform implemented by the FFT in Python.
– Peter K.
Mar 23, 2022 at 15:40
• 1. When n=1, the function is x, and the continuous FT of a*x can be obtained by a * the FT of x. 2. Yes. It is not correct to compare the result from discrete FT and continuous FT. Mar 23, 2022 at 16:17

Your code implements the Discrete Fourier Transform (DFT) your equations describe the continuous Fourier Transform (CFT). They are quite different.

The DFT is applicable if the signal is discrete in both time and frequency, which implies that the signals are also periodic time and frequency as well.

Your signal is neither periodic or even just limited in time, frequency or amplitude. Converting it to a discrete signal will generate large errors, no matter how you do it. You are in essence approximating the CFT of a sawtooth wave not a ramp.

Sometimes the DFT can be used to numerically approximate the results of a CFT, but in your case this is not going to work.

• I modify the title and the first equation because the signal is discrete. Can you elaborate on why the DFT is only applicable to signals that are "periodic time and frequency as well"? Mar 23, 2022 at 15:30
• @Jayz That doesn't change that the table you refer to is for the Fourier transform (continuous time variable) not the discrete Fourier transform as implemented in Python's scipy.fft.fft.
– Peter K.
Mar 23, 2022 at 15:42
• Everything that's discrete in one domain is periodic in the other. That's a fundamental mathematical property of the Fourier Transform. Mar 23, 2022 at 18:40