This is probably a very naive question, but here it is.
I want to calculate the Fourier transform of the function f (x). So I define a numpy X array and pass it through a vectorized function f. Now, if I calculate the FFT of this array f (X), it is not the Fourier transform of the function f (x), as if I were doing this on a piece of paper. For example, if I calculate the FFT of a Gaussian, I have to get a Gaussian or array, the real part of which will be very close to Gaussian.
here is the code. let me know what I need to change to get the usual Fourier transform.
import matplotlib.pyplot as plt import numpy as np N = 128 x = np.linspace(-5, 5, N) y = np.exp(-x**2) y_fft = np.fft.fftshift(np.fft.fft(y).real) plt.plot(x, y_fft) plt.show()
let me repeat it. I want to calculate the Fourier transform of any function (e.g., Gaussian). FFT is a way to calculate the Fourier transform from an array of numbers, but it's not the same as simply sampling a continuous Fourier transform formula.
source share