0
$\begingroup$

I am testing Mathematica's DFT algorithm using one of the test cases provided in the documentation, of a noisy sine function with a frequency of 0.15 cycles per sample:

FourierTestData[n_] := Table[N[Sin[30 2 Pi x/200] + (RandomReal[] - 1/2)], {x, n}]

I find the estimated period according to the FFT:

Frequency[data_] := TakeLargest[Drop[Abs[Fourier[data, FourierParameters -> {-1, 1}]], -Round[Length[data]/2]] -> {"Index"}, 1];

I test this method across a range of numbers of points (without changing the period or any other parameters), like so:

Table[{i*200, First[First[Period[FourierTestData[i*200]]]]}, {i, 1, 200, 0.1}]

I find that the reported frequency is equal to the actual frequency times the number of points, i.e. the length of the test sequence. Why would this be the case?

$\endgroup$
2
  • 2
    $\begingroup$ For the discrete Fourier transform, the complex amplitude a[[i]] represents a frequency of i-1 cycles per total length of the input sequence. This is implicit in the definition of the DFT, reflected in the detailed definition in the Mathematica documentation. $\endgroup$
    – John Doty
    Nov 4, 2021 at 0:20
  • 3
    $\begingroup$ I have put some notes on how Mathematica implements Fourier here . The notes explain how to generate a frequency axis. $\endgroup$
    – Hugh
    Nov 4, 2021 at 6:45

1 Answer 1

1
$\begingroup$

As per Hugh and John's comments, this is because in a discrete Fourier transform, the frequency represented by the n-th point (in cycles/sample) is equal to (n-1)/N, where N is the total number of points.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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