Message Boards Message Boards

0
|
6266 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Using LogLogPlot for a user defined function

Posted 9 years ago

I am attempting to teach myself how to use the Allan Variance/Deviation for working with different types of noise. In the following code, a random gaussian white noise is created, and the function computes what the Allan Deviation is for each value of m. I expect the plot should look like a decay, however I can't seem to figure out the correct way to plot this function.

WN = WhiteNoiseProcess[NormalDistribution[0, 10]];
aD[m_] := 
 Module[{data, points, yBinLst, meanLst}, 
  data = RandomFunction[WN, {1, 10000}];
  points = data["Values"];
  yBinLst = Partition[points, m];
  meanLst = Mean /@ yBinLst;

  Sqrt[Total[Differences[meanLst]^2]/(2 (Length[yBinLst] - 1))]
  ]

The values for each Allan Deviation as a function of m can be extracted in the following step (so I know they're being generated):

SeedRandom[0];
myValuesForM = Range[1, 5000, 1];
aD /@ myValuesForM;

If I try to do

LogLogPlot[aD[m],{m,1,5000}]

It gives a slew of errors:

  • Partition::ilsmp: Single or list of positive machine-sized integers expected at position 2 of Partition[{-10.0041,-1.86738,11.3378,-10.8579,14.3292,-20.8941,6.60082,<<37>>,-21.7658,-6.81784,0.472543,2.26544,-10.0748,11.6813,<<9950>>},m]. >>
  • artition::ilsmp: "Single or list of positive machine-sized integers expected at position 2 of Partition[-0.1166830194847478`,Mean[m]]. \!(*ButtonBox[\">>\", Appearance->{Automatic, None}, BaseStyle->\"Link\", ButtonData:>\"paclet:ref/message/General/ilsmp\", ButtonNote->\"Partition::ilsmp\"])"
  • Differences::listrp: List or SparseArray or StructuredArray expected at position 1 in Differences[Partition[-0.116683,Mean[m]]]. >>

and so on...

I have absolutely no idea what I am doing wrong... My thesis advisor suggested I make aD a function of data and m Each Allan Plot example I look at on the internet is done in MatLab or R, which doesn't help because I don't know those languages at all. It is difficult enough attempting to figure out how use Mathematica without attempting to deconstruct another programming language to figure out what I am doing wrong. In any case, I hope this is just a small error due to my experience... Thanks in advance for the time taken to read this and or help. :)

This is an example of what I am attempting to accomplish

POSTED BY: Sean Alto
Posted 9 years ago

LogLogPlot doesn't realize that you only want to probe your aD function at integer values of m.

Try this instead, which creates a list of values of your function at the first 5000 integer values of m and then plots just those points.

ListLogLogPlot[Table[aD[m], {m, 1, 5000}]]

which gives this

enter image description here

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

Group Abstract Group Abstract