MathGroup Archive 2004

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

Search the Archive

Re: Fitting question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51670] Re: Fitting question
  • From: koopman at sfu.ca (Ray Koopman)
  • Date: Wed, 27 Oct 2004 23:45:03 -0400 (EDT)
  • References: <clco37$q7i$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

János <janos.lobb at yale.edu> wrote in message news:<clco37$q7i$1 at smc.vnet.net>...
> I have two lists.  One of them contains the running total of some 
> quantity per cycles, the other contains the totals per cycles.  Here 
> they are:
> 
> In[35]:= runtotpergen = {1, 23, 136, 568, 1735, 4382, 9099,
>                          16384, 25993, 36694, 47752, 58044, 66761,
>                          73534, 78429, 81753, 83750, 84873, 85482,
>                          85779, 85937, 86025, 86069, 86081, 86087}
> 
> In[36]:= totpergen = {1, 22, 113, 432, 1167, 2647, 4717, 7285,
>                       9609, 10701, 11058, 10292, 8717, 6773, 4895, 3324,
>                       1997, 1123, 609, 297, 158, 88, 44, 12, 6}
> 
> I am trying to find out the analytical form of a function which fits 
> best totpergen. [...]
> 
> totpergen is not symmetrical, [...]
> 
> I feel that Mathematica has the capability to find the best fitting 
> function without too much manual trials.    Any hint how to do that ?

This fits a shifted gamma density to the first three moments of totpergen.
It handles the asymmetry naturally and fits well.

In[1]:= n = Last[runtotpergen = {1, 23, 136, 568, 1735, 4382, 9099,
        16384, 25993, 36694, 47752, 58044, 66761, 73534, 78429, 81753,
        83750, 84873, 85482, 85779, 85937, 86025, 86069, 86081, 86087}]
Out[1]= 86087

In[2]:= m = Length[totpergen = {1, 22, 113, 432, 1167, 2647, 4717, 7285,
        9609, 10701, 11058, 10292, 8717, 6773, 4895, 3324, 1997, 1123,
        609, 297, 158, 88, 44, 12, 6}]
Out[2]= 25

In[3]:= <<Statistics`ContinuousDistributions`;
        #@GammaDistribution[a,b]&/@{Mean,Variance,Skewness} //InputForm
Out[4]//InputForm= {a*b, a*b^2, 2/Sqrt[a]}

In[5]:= f[a_,b_,c_,x_] := PDF[GammaDistribution[a,b],x-c] /; x >= c

In[6]:= N@{mean = totpergen.Range[m]/n, 
            var = totpergen.(Range[m]-mean)^2/n,
           skew = totpergen.(Range[m]-mean)^3/n * var^(-3/2)}
        {a = 4./skew^2, b = Sqrt[var/a], c = mean - a*b}
Out[6]= {11.2316, 9.49626, 0.305409}
Out[7]= {42.8842, 0.470574, -8.94861}

In[8]:= Plot[n*f[a,b,c,x],{x,1,m}, Epilog->{PointSize[.015],
             Point/@Transpose@{Range@m,totpergen}}];


  • Prev by Date: Re: Bug in Graphics Text under Linux
  • Next by Date: Re: Combining different colored 3-D Plots
  • Previous by thread: Re: Fitting question
  • Next by thread: Re: Re: Fitting question