MathGroup Archive 2003

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

Search the Archive

Re: Re: finding periodicity in a set

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39304] Re: [mg39283] Re: finding periodicity in a set
  • From: Dr Bob <drbob at bigfoot.com>
  • Date: Mon, 10 Feb 2003 01:07:53 -0500 (EST)
  • References: <b1t5bj$90v$1@smc.vnet.net> <b1votq$pk5$1@smc.vnet.net> <200302090950.EAA17966@smc.vnet.net>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

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

On Sun, 9 Feb 2003 04:50:32 -0500 (EST), Scott A Centoni 
<scentoni at stanford.edu> wrote:

> The following response from Mihajlo Vanevic has solved my problem, and I 
> thought it would be helpful to others as well:
>
> >Ok, now I get it... ;o)
> >
> >But if you know that your error is, say, less than 0.01,
> >try this dirty (but rather fast) approach:
> >
> >In[]:=
> >xlist = 0.202 + 1.618 Table[0.001 Random[] + Random[Integer, {3, 17}], 
> {100}];
> >
> >In[]:=
> >error = 0.01;
> >
> >In[]:=
> >xxlist = First /@ Split[Sort[xlist], #2 - #1 < error &];
> >
> >In[]:=
> >Fit[xxlist, {1, x, x^2}, x]
> >
> >Regards,				
> >         Mihajlo Vanevic
> >         mvane at EUnet.yu
> >         2003-02-07
> >
> >**************************************************************
> >*    At 2003-02-07, 03:07:00
> >*        Scott A Centoni, scentoni at stanford.edu  wrote:
> >**************************************************************
> >
> >>Thanks for the responses!  (Particularly from Matt Flax.)  I see now
> >>that my sample fake data set is misleading, I should have specified it
> >>as
> >>
> >>xlist = 0.202 + 1.618 Table[0.001 Random[] +
> >>Random[Integer,{3,17}],{100}]
> >>
> >>to make it crystal clear that no correlation between successive items 
> in
> >>the list is implied and that the order is completely irrelevant.
> >>
> >>Scott A Centoni wrote:
> >>
> >>>I have a list of coordinates where I want to find the period and 
> offset
> >>>(modulo the period).  To illustrate, let's create the fake data set
> >>>
> >>>xlist = 0.202+1.618(0.001 Random[ ] + Range[3, 17])
> >>>
> >>>I want a function that will return
> >>>
> >>>periodicity[xlist]
> >>>
> >>>{1.618,0.202}
> >>>
> >>>_pace_ an error in the third decimal place.  Note that the order of 
> the
> >>>data in the list is irrelevant; it's to be considered a set, not a 
> vector.
> >>>
> >>>My first thought is to turn this into a sum of delta functions
> >>>
> >>>xfunc = Plus@@(DiracDelta[x-#]&/@xlist)
> >>>
> >>>and then Fourier transform this
> >>>
> >>>kfunc = FourierTransform[xfunc,x,k]
> >>>
> >>>and find the first nontrivial peak.  Does someone have a better way?  
> Or
> >>>if not, what's the "best" way of locating the peak?
> >>>
> >>>Thanks,
> >>>Scott
> >
> >**************************************************************
> >
> >
> >
> >
> >
>
>



-- 
majort at cox-internet.com
Bobby R. Treat



  • Prev by Date: Detecting unsuccessful computations
  • Next by Date: Input output disappear
  • Previous by thread: Re: finding periodicity in a set
  • Next by thread: Re: Re: Re: finding periodicity in a set