Good day everyone,

I'm new in mathematica.

I got these values over time (each value was obtained every 100 milliseconds):

data = {0.627896`, 0.205004`, 0.259237`, 1.059125`, 0.832184`,
 0.587992`, 0.565537`, 0.527323`, 0.460228`, 0.471958`, 0.26696`,
 0.75367`, 0.892273`, 0.789401`, 1.089945`, 0.579791`, 0.421917`,
 0.677286`, 0.34936`, 0.16841`, 0.24775`, 0.813205`, 0.421242`,
 0.15486`, 0.612315`, 0.953073`, 0.561099`}


enter image description here

How can I get the power spectrum density? And how can I separate low (0.6 Hz =<) and high (>0.6 Hz) frequencies?

Thank you so much.

  • 1
    $\begingroup$ Get your data as a TimeSeries ts = TimeSeries@Transpose[{0.1*Range[0, Length[data] - 1], data}];, then use PowerSpectralDensity[ts, w] if that's what you mean by spectrum density, or you could use Periodogram[data, SampleRate -> 10] and PeriodogramArray[data, SampleRate -> 10]. This has been asked a number of times before on this site. You'll need more data to get meaningful values: 27 samples is quite low. $\endgroup$
    – flinty
    Nov 2, 2021 at 22:00

1 Answer 1


You have very few points. I don't think you want a power spectrum which implies some averaging. Instead let's look at the spectrum of the Fourier transform. First I identify some basic facts about your data.

sr = 1000./100; (* Sample rate *)
nn = Length@data; (* Number of points *)
m = Mean[data]; (* Mean of data values *)

Have I understood your sampling time correctly? I think you are sampling at 10 points per second.

The mean value is a nuisance when looking at frequency content because it produces a frequency component at 0 Hz. It is best to remove the mean value which I do next. Then I work out the frequency content of the data using Fourier. Finally I work out a frequency axis for your data.

d1 = data - m;
ft = Fourier[d1, FourierParameters -> {-1, 1}];
ff = Table[(n - 1) sr/(nn - 1), {n, nn}];

The spectrum calculated covers positive and negative frequencies. The negative frequencies are just a mirror image of the positive ones and can be ignored. See here for details of Fourier analysis. Now we can plot.

   ListLinePlot[Transpose[{ff, Abs[fd]}][[1 ;; (nn - 1)/2]], 
 Frame -> True, FrameLabel -> {"Frequency/Hz", "Modulus"}]

enter image description here

As you can see you have very few data points and there is no particular split between low and high frequencies. Can you get more data and post that? We would get a better spectrum then.

Hope that helps.


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.