2
$\begingroup$

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?

$\endgroup$
2
  • 3
    $\begingroup$ Did you look at Fourier? $\endgroup$
    – paw
    Commented Nov 24, 2015 at 14:02
  • $\begingroup$ Yep, I tried that, but the outcome was totally different than the numerical Fourier transformation of the function. $\endgroup$ Commented Nov 24, 2015 at 14:50

1 Answer 1

4
$\begingroup$

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}]

test data

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]

better test data

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"]}]

fourier transform

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]
$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.