# get period from non-uniform discrete data by Fourier transfomation

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:

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]


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

• And the function in your real use case is such that you cannot interpolate and resample uniformly? Aug 16, 2016 at 9:44
• 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?
– Hugh
Aug 16, 2016 at 9:49
• 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/… Aug 16, 2016 at 10:21
• There is a possibly helpful discussion here Aug 16, 2016 at 14:26

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]


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.