1
$\begingroup$

After playing around with calculating the Overlapping Allan Deviation for my research project (and with much help from this community), I have finally resolved a correct listloglogplot for simulated white noise.

WN = WhiteNoiseProcess[NormalDistribution[0, 10]];
data = RandomFunction[WN, {1, 5000}];
ListPlot[data, Filling -> Axis]
(*Averaging Factor*)
f = 3;
aDev[m_] := 
  Module[{points, yBinLst, y, M},
    points = data["Values"];
    yBinLst = Partition[points, m];
    y = Mean /@ yBinLst;
    M = Length[yBinLst];
   Sqrt[
     Sum[
       (Sum[(y[[i + f]] - y[[i]])^2, {i, j, j + f - 1}]/2)*f^2*(M - 2*f + 1), 
       {j, 1, M - 2*f + 1}]]]
 SeedRandom[0];
 mValues = Range[2, 2500, 1];
 aData = aDev /@ mValues;
 ListLogLogPlot[aData]

Similar to all the research I've read concerning the Allan Variance, the output listloglogplot appears to have a -.5(ish) slope, which is consistent with examples from textbooks. However, is it possible to add a fit or "trendline" to a graphic showing the slope is approximately correct?

$\endgroup$
  • $\begingroup$ The figure does not appear to be a straight line so why would you want to summarize it with a slope as if it were a straight line? Is there just a particular section that is expected to be a straight line? $\endgroup$ – JimB Jun 10 '15 at 17:01
  • $\begingroup$ In the listloglogplot a trend line with a slope of -.5 should be discernable from the graphic. This slope correlates with White Frequency Noise when viewed in a Log Log plot (which is what was initially generated). My hope is to expand this to identify different types of noise from different data sets, and eventually atomic clock noise. I understand it isn't really a straight line, nevertheless, a best fit line should show the expected -.5 slope. $\endgroup$ – Sean Alto Jun 10 '15 at 17:30
  • $\begingroup$ Would you mind showing the figure? We'll just have to agree that "goodness-of-fit" can be in the eye of the beholder (and can require subject matter knowledge which I don't have for this particular application). $\endgroup$ – JimB Jun 10 '15 at 17:36
  • $\begingroup$ Link to graphic link to similar example $\endgroup$ – Sean Alto Jun 10 '15 at 17:41
6
$\begingroup$

You data has lots of zeros towards the end. I found out the end of the non-zero data from

nn = Position[aData, 0, 1, 1][[1, 1]] - 1

(* 832 *)

Then to get a straight line I worked out log coordinates for your data

lgData = Table[{N[Log[n]], Log[aData[[n]]]}, {n, nn}];

Now we can do a DynamicModule to work out a tangent to the data to get a straight line.

DynamicModule[{n1 = 1, n2 = nn, line, x},
 Column[{
  Row[{ IntervalSlider[Dynamic[{n1, n2}], {1, nn, 1}, 
  Method -> "Push", ImageSize -> 6 72, 
  Appearance -> {"Markers", "Labeled"}]}],

  Dynamic[line = Fit[lgData[[n1 ;; n2]], {1, x}, x]],
  Dynamic[Show[
     ListLogLogPlot[aData, ImageSize -> 6 72],
     Plot[line, {x, Log[1], Log[nn]}, PlotStyle -> Red, 
      PlotRange -> All]
   ]]
   }]
    ]

Mathematica graphics

Now you can choose an interval of point numbers (3 to 429 in the plot) to decide where you want to put your line...

$\endgroup$
  • $\begingroup$ That is exactly what I was looking for! Thank you very much. $\endgroup$ – Sean Alto Jun 10 '15 at 17:56

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.