Following from Sven Marnach's answer, a simpler version would be as follows:
from pylab import * N = 128 x = ifftshift(arange(-5,5,5./N)) y = exp(-x*x) y_fft = fft(y) / sqrt(2 * N) plot(fftshift(y)) plot(fftshift(y_fft)) show()
This gives a graph similar to the one above.
The key (and this seems odd to me) is that NumPy assumed that the order of the data β both in the frequency and time domains β should be set to zero. This is not what I would expect from other FFT implementations, such as the FFTW3 libraries in C.
This was slightly distorted in the answers from unutbu and Steve Tjoa above, because they take the absolute value of the FFT in front of its graphics, thereby eliminating the phase problems that arise because they do not use the "standard order" in time.
source share