2
$\begingroup$

I have the current setup for calculating Allan Deviation:

ADEV

which was coded as:

Sqrt[Total[Differences[y]^2]/(2 (M - 1))]

However, after doing some research, overlapping Allan Deviation is what I need to calculate, which looks like:

enter image description here

For the life of me, I can't figure out how to adjust my code for this change... I attempted to put it in as you see above (in fact, this was done with the math palette), but it runs for a long time, then when I graph the results with ListLogLogPlot it gives an empty graph. I am guessing Mathematica doesn't understand the subscript is being used as an index. I searched the Summation documentation, however, it doesn't discuss how to enter the portions of a function.

Here is a copy of the code (which I am sure some of you will recognize, as I asked last week about some of the nuances of working with this function in Mathematica, mapping, tables, etc).

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

  Sqrt[Total[Differences[y]^2]/(2 (M - 1))]
  ]
SeedRandom[0];
mValues = Range[2, 5000, 1];
aData = aDev /@ mValues;
ListLogLogPlot[aData]
| improve this question | | | | |
$\endgroup$
  • $\begingroup$ Have you tried using Indexed or Part rather than the subscripts in your Sum? $\endgroup$ – Mr.Wizard May 27 '15 at 20:34
  • $\begingroup$ Including code (no matter how messy) for your second image would be nice so we don't have to reenter it manually. $\endgroup$ – Mr.Wizard May 27 '15 at 20:36
  • $\begingroup$ Sqrt[(\!\( \*UnderoverscriptBox[\(\[Sum]\), \(j = 1\), \((M - 2 m + 1)\)]\( \*UnderoverscriptBox[\(\[Sum]\), \(i = j\), \((j + m - 1)\)] \*SuperscriptBox[\(( \*SubscriptBox[\(y\), \(i + m\)] - \*SubscriptBox[\(y\), \(i\)])\), \(2\)]\)\))/2 m^2 (M - 2 m + 1)] Like this? Also, sorry about that. :/ $\endgroup$ – Sean Alto May 27 '15 at 20:44
  • $\begingroup$ Yes, that can be pasted into Mathematica and it saves work retyping. $\endgroup$ – Mr.Wizard May 27 '15 at 20:45
  • 1
    $\begingroup$ There may be faster ways to perform the computation if speed is a limiting factor. For example you could start from Differences[y, 1, m]^2. $\endgroup$ – Mr.Wizard May 27 '15 at 21:08
2
$\begingroup$

Maybe what you want?

aDev2[m_] :=
 Module[{data, points, yBinLst, y, M},
   data = RandomFunction[WN, {1, 10000}];
   points = data["Values"];
   yBinLst = Partition[points, m];
   y = Mean /@ yBinLst;
   M = Length[yBinLst];
   Sum[(y[[i + m]] - y[[i]])^2, {j, 1, M - 2 m + 1}, {i, j, j + m - 1}]/
     2 m^2 (M - 2 m + 1) // Sqrt
]

SeedRandom[0];
mValues = Range[2, 5000, 1];
aData = aDev2 /@ mValues;
ListLogLogPlot[aData]

enter image description here

| improve this answer | | | | |
$\endgroup$

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.