This problem is perhaps a little bit more mathematical than programmatic. I'm using Fourier
to analyze my data. Suppose I have a data set
datainv3 = InverseFourier[#^(-3) & /@ Range@1000]
Now I make up a data series with a -3 spectrum. Analyze it with Fourier
:
ListLogLogPlot[{Abs[Fourier[datainv3]],
Abs[Fourier[datainv3[[1 ;; 999]]]],
Abs[Fourier[datainv3[[1 ;; 800]]]]}, Frame -> True]
This gives me:
The blue line looks fine. But what is wrong with the orange and green ones? Fourier
doesn't return me a good spectrum, even if I use 99.9% data. Why will this happen?
Is there a way that I can still generate a good spectrum with incomplete data? Perhaps I should use something different rather than a simple Fourier
? Because real data is never infinitely long, and I am afraid that Fourier
will give me a very different result if I slightly vary the length of the signal fed into it——That's horrible.
I am sorry to mention this question again, because the problem is still NOT solved even after I make up the other 'half' spectrum as suggestted by @flinty.
considering the following code:
n = 1000;
spectrum = Range[n]^-3;
datainv3 = InverseFourier[Join[spectrum, Reverse@spectrum]];
Show[
LogLogPlot[x^-3, {x, 1, 2 n}, PlotStyle -> {Gray,Dashed},
Filling -> Bottom],
ListLogLogPlot[Abs[Fourier[datainv3[[;; 2 n - 1]]]], PlotStyle -> Red],
ListLogLogPlot[Re[Fourier[datainv3[[;; 2 n - 1]]]], PlotStyle -> Green]]
It gives this:
It is, emmm, I have to say, not much better than the original result.
It is a bit better if I Re
datainv3 before taking the Fourier
. The code reads:
n = 1000;
spectrum = Range[n]^-3;
datainv3 = InverseFourier[Join[spectrum, Reverse@spectrum]];
Show[
LogLogPlot[x^-3, {x, 1, 2 n}, PlotStyle -> {Gray, Dashed}, Filling -> Bottom],
ListLogLogPlot[Abs[Fourier[Re@datainv3[[;; 2 n - 1]]]], PlotStyle -> Red],
ListLogLogPlot[Re[Fourier[Re@datainv3[[;; 2 n - 1]]]], PlotStyle -> Green],
ListLogLogPlot[Re[Fourier[Re@datainv3[[;; 2 n - 10]]]], PlotStyle -> Pink]
]
It gives me this
It looks better than the above picture but can hardly be satisfying. datainv3
is 2000 numbers long. However, the Fourier
spectrum varies significantly if I miss out on only 10 data points. Does this mean that the Fourier
spectrums cannot be compared if they are from original data series with different lengths?
I mean, in my understanding, the spectrum of a signal is its intrinsic properties. The spectrum should not vary greatly if we analyze examples with different lengths. For example, the turbulent kinetic energy spectrum is a -5/3 power law (http://brennen.caltech.edu/fluidbook/basicfluiddynamics/turbulence/turbulencescales.pdf). It is a -5/3 power law if you observe turbulence for 10 minutes, and it is a -5/3 power law if you observe turbulence for 1 hour. Perhaps the low-frequency part may vary a bit as the sign length changes (longer signal length may introduce the lower frequency part), but the high-frequency part should remain the same because the latter represents the small-scale fluctuation.
Re[Fourier[Re@datainv3[[;; 2 n - 10]]]]
- it should be justRe[Fourier[datainv3]]
$\endgroup$Abs[Fourier[datainv3]]
is a perfect blue line, even though I miss the other half of the spectrum when generating datainv3. However,Abs[Fourier[datainv3[[1;;-2]]]]
looks awful. Then I ask, why didn'tFourier
return me a good spectrum, even if I use 99.9% data. $\endgroup$ListLogLogPlot[Re[Fourier[Re@Join[datainv3[[;; n - 10]]]]]]
doesn't give a good spectrum. $\endgroup$