MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Re: finding periodicity in a set

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39321] Re: [mg39304] Re: [mg39283] Re: finding periodicity in a set
  • From: "Mihajlo Vanevic" <mvane at eunet.yu>
  • Date: Tue, 11 Feb 2003 04:41:58 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Here is something similar to Dr Bob's idea for small sample size...
(but more accurate, I think)


<< Statistics`DescriptiveStatistics`

Clear[mihajlo2];

mihajlo2[xlist_, dr_:0.1, error_:0.01] :=
    Module[
      {xxlist, gaps, ratios, rationalRatios, lcm, intRatios, xvals, linefit, 
        a, b},
      
      xxlist = Mean /@ Split[Sort[xlist], #2 - #1 < error &];
      gaps = ListConvolve[{1., -1.}, xxlist];
      ratios = gaps/Min[gaps];
      rationalRatios = Rationalize[ratios, dr];
      lcm = LCM @@ Denominator[rationalRatios];
      intRatios = rationalRatios*lcm;
      xvals = FoldList[Plus, lcm, intRatios];
      linefit = Fit[Transpose[{xvals, xxlist}], {1, x}, x];
      {a, b} = CoefficientList[linefit, x];
      {Mod[a, b], b, Max[xvals]}
      ];

test:

xlist := 0.202 + 1.618 Table[0.001 Random[] + Random[Integer, {3, 17}], {20}];
TableForm[Table[{{mihajlo2[xlist]}}, {50}]]


and

xlist := 0.202 + 1.618 Table[0.001 Random[] + Random[Integer, {3, 17}], {4}];
TableForm[Table[{{mihajlo2[xlist]}}, {50}]]


Mihajlo

**************************************************************
*    At 2003-02-10, 01:07:00 
*        Dr Bob, drbob at bigfoot.com  wrote:
**************************************************************
>Mihajlo's method doesn't work well with small sample sizes, so I'd suggest 
>this:
>
><< Statistics`DescriptiveStatistics`
>xlist = 0.202 + 1.618 Table[0.001 Random[] + Random[Integer, {3, 17}], 
>{20}];
>error = 0.5;
>xxlist = Mean /@ Split[Sort[xlist], #2 - #1 < error &];
>Fit[xxlist, {1, x, x^2}, x];
>{a, b, c} = CoefficientList[, x];
>{Mod[a, b], b}
>gaps = Subtract @@@ Transpose@{Rest@xxlist, Drop[xxlist, -1]};
>ratios = gaps/Min@gaps;
>gcd[ratios_List] := Module[{n = 2, k},
>    While[n < 10 && (k = n/GCD @@ Round[n*ratios]) â?¥ n, n++];
>    k
>    ]
>b2 = Min[gaps]/gcd@ratios;
>{a2 = Mean@Mod[xxlist, b2], b2}
>
>{1.18984, 1.39711} (* Mihajlo's method with Mean in place of First *)
>{0.207753, 1.6175} (* better *)
>
>With as few as four samples, this often returns the right period, while the 
>other method rarely gets it right even with 20 samples.
>
>You shouldn't make the error estimate too small --- a fourth of the period 
>is about right.  (But you don't know the period in advance.)  A more 
>complete method would adjust the error estimate after estimating the 
>period, to see if the answer changes.
>
>Bobby







  • Prev by Date: Re: I need some help about this error
  • Next by Date: Re: Detecting unsuccessful computations
  • Previous by thread: Re: Re: finding periodicity in a set
  • Next by thread: Re: Re: Re: Re: finding periodicity in a set