Felix Richter <felix <at> physik3.uni-rostock.de> writes: > > > Do your answers differ from the theory by a constant factor, or are > > they completely unrelated? > > No, it's more complicated. Below you'll find my most recent, more stripped > down code. > > - I don't know how to scale in a way that works for any n. > - I don't know how to get the oscillations to match. I suppose its a problem > with the frequency scale, but usage of fftfreq() is straightforward... > - I don't know why the imaginary part of the FFT behaves so different from > the > real part. It should just be a matter of sin vs. cos. > > Is this voodoo? > > And I didn't find any example on the internet which tries just to reproduce > an > analytic FT with the FFT... > > Thanks for your help!
This is not voodoo, this is signal processing, which is itself harmonic analysis. Just because the Fast Fourier Transform is fast doesn't mean that this stuff is easy. You seem to be looking for a simple relationship between the Fourier Transform (an integral transform from L^2(R) -> L^2(R)) of a function f and the Discrete Fourier Transform (a linear transformation from R^n to R^n) of the vector of f sampled at regularly-spaced points. Such a simple relationship does not exist. That is why you found no such examples on the internet. The closest you might come is to study the surprisingly cogent explanation at http://en.wikipedia.org/wiki/Fourier_analysis of the differences between the various types of Fourier analysis. Remember that the DFT (as implemented by an FFT algorithm) is *not* an approximation to the Fourier transform, but rather a streamlined way of computing the coefficients of a Fourier series of a particular periodic function (that contains a finite number of Fourier modes). Rather than look for errors in the scaling factors or errors in your code, I think that you should try to expand your understanding of the (subtly) different types of Fourier representations. -Neil _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
