# Discrete Fourier Transformation

Assuming I have a function $f(x)$. I can use a numerical Fourier transformation:

NFourierTransform[]


to find some points of $F(\omega)$. How can I do the same when I have not $f(x)$ but some points of it, i.e. $f(x_i)$.

For example:

PDF[NormalDistribution[0, 1], x]
f[x_] := E^(-(x^2/2))/Sqrt[2 \[Pi]]
Testdata = Array[f, 100, {-2, 2}];


Fourier[Testdata] gives a complex dataset back, but the Fourier transform should be again a real Gaussian?

• Did you look at Fourier?
– paw
Nov 24 '15 at 14:02
• Yep, I tried that, but the outcome was totally different than the numerical Fourier transformation of the function. Nov 24 '15 at 14:50

The Gaussian f[x] you are transforming is given by your PDF statement. The corresponding frequency-domain Gaussian is given by

FourierTransform[f[x], x, w]


which is the same function with w replacing x, that is, f[w]. The discrete Fourier transform on numerical data, implemented by Fourier, assumes periodicity of the input function. Hence, the Testdata you supply is seen by Fourier as a function of the following form, with an infinite number of peaks ranging from minus infinity to infinity.

Testdata = Array[f, 100, {-2, 2}];
ListLinePlot[Join[Testdata, Testdata, Testdata], Frame -> True,
DataRange -> {-150, 150}]


Note that the function does not reach zero, as an actual Gaussian would (in the limit). This offset means that you are not actually transforming a Gaussian function when you input Testdata to Fourier. A better approximation would be to sample more of the tails of the true Gaussian. In addition, with your Array formulation, the replications assumed by Fourier cause a double-sampling the points at f[-2] and at f[2]. It is better to match endpoints so that, when replicated, the (approximate) Gaussians match seemlessly. The following table of f[x] extends the range to better sample the tails, matches endpoints, and centres on zero (the first sample).

TestdataFull = RotateRight[Table[f[x], {x, -5.0, 5.0 - 1.0/10., 1.0/10.}], 50];
ListLinePlot[TestdataFull, Frame -> True]


Fourier returns complex data even if the input signal is real. However, by matching endpoints and sampling the Gaussian more fully, the imaginary part is now essentially noise.

GraphicsRow[{
ListLinePlot[Re[Fourier[TestdataFull]][[Range[20]]],
PlotRange -> All, Frame -> True, PlotLabel -> "Real Component"],
ListLinePlot[Im[Fourier[TestdataFull]][[Range[20]]],
PlotRange -> All, Frame -> True, PlotLabel -> "Imaginary Component"]}]


Take the magnitude of the complex, yet essentially real, data returned by Fourier, and centre the peak. There's your real Gaussian.

ListLinePlot[RotateRight[Abs[Fourier[TestdataFull]], 50],
PlotRange -> All, Frame -> True]