I found that it seems the fourier function only treat the discrate data with equal timeinterval, as an experiment, let us consider the following example:

n=4*500/(2 Pi);
testData = Table[N@Sin[500 x], {x, 0, 1, 1/n}];
ListLinePlot[Abs[Fourier[testData]], PlotRange -> All]

which output likes: enter image description here

To test it depends on the partition of interval, let us define a randon positon in [0,1]

dpos = Sort[Table[Random[], {i, n}]] // DeleteDuplicates;
(*compare to 
 dpos = Sort[Table[i/n, {i, n}]] // DeleteDuplicates;

then construct the data as before,

testDatar = N@Sin[500 dpos ];

this time, you will find the output of Fourier is quite different,

ListLinePlot[Abs[Fourier[testDatar]], PlotRange -> All]

enter image description here

My question is, how to get the picture as the first one?

  • $\begingroup$ And the function in your real use case is such that you cannot interpolate and resample uniformly? $\endgroup$
    – C. E.
    Aug 16, 2016 at 9:44
  • $\begingroup$ I was just about to suggest the approach of C.E. However are you after the full spectrum or just the frequency and amplitude of your time history? $\endgroup$
    – Hugh
    Aug 16, 2016 at 9:49
  • 1
    $\begingroup$ Fourier works on evenly sampled data. While I know there are FFT methods developed for handling non-evenly sampling, I'd recommend to use a different method to start with, e.g. the Lomb-Scargle periodogram: mathematica.stackexchange.com/questions/123884/… $\endgroup$
    – corey979
    Aug 16, 2016 at 10:21
  • 2
    $\begingroup$ There is a possibly helpful discussion here $\endgroup$
    – BlacKow
    Aug 16, 2016 at 14:26

1 Answer 1


The following estimates a spectrum, returning peaks at the anticipated frequencies.

n = 4*500/(2 Pi);
dpos = Sort[Table[Random[], {i, n}]] // DeleteDuplicates;
testDatar = N@Sin[500 dpos];
spec[w_?NumericQ] := Exp[-I w dpos].testDatar
Plot[Abs[spec[w]], {w, -600, 600}, PlotRange -> All]

enter image description here

This may be adequate for your requirements. However, it does not exploit the speed of the FFT and (like your original unweighted Fourier transform) your ability to see small sinusoids in the presence of large sinusoids will be limited.

There are ways round these problems, but this simple solution may be enough for you.


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.