Group Abstract Group Abstract

Message Boards Message Boards

1
|
1.9K Views
|
8 Replies
|
7 Total Likes
View groups...
Share
Share this post:

Wrong frequencies in Periodogram?

POSTED BY: Vladimir Ivanov
8 Replies

Hi Vladimir, yes that is a bug. It is due to an incorrect setting of the DataRange option. To correct please see the attached notebook.

Attachments:
POSTED BY: Daniel Lichtblau

I guess this is because your data are not perfectly periodic - in the sense that the first value is not identical to the last one. To assure this you just have to include one more point, e.g.:

n = 100;
data = Cos[2 \[Pi] Range[0, n]*0.25] // N;

The length of the data list is now 101, and the periodogram is probably like you are expecting it.

POSTED BY: Henrik Schachner

Try it using Most[] on that range; it may be that you included one point too many.

POSTED BY: Daniel Lichtblau

Well - ok! I do admit that I was simply not willig to even consider a bug in a function which belongs to the prominent Fourier-family ...

At least PeriodogramArray[] seems to give a correct result:

n = 100;
data = Cos[2 \[Pi] Range[0, n - 1]*0.25] // N;
pdg = Periodogram[data, PlotRange -> All, ScalingFunctions -> {"Linear", "Linear"}, PlotStyle -> Dotted];
pdata = MapIndexed[{(First[#2] - 1)/n, #1} &, PeriodogramArray[data]];
Show[ListLinePlot[pdata[[;; 50]], PlotRange -> All, GridLines -> {{.25}, None}], pdg]

enter image description here

POSTED BY: Henrik Schachner

Mariusz, thank you.

POSTED BY: Vladimir Ivanov
POSTED BY: Vladimir Ivanov
POSTED BY: Vladimir Ivanov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard