Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Re: Fitting question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51695] Re: [mg51670] Re: Fitting question
  • From: János <janos.lobb at yale.edu>
  • Date: Fri, 29 Oct 2004 03:39:45 -0400 (EDT)
  • References: <clco37$q7i$1@smc.vnet.net> <200410280345.XAA09855@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On Oct 27, 2004, at 11:45 PM, Ray Koopman wrote:

> 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}}];
>

Wow !!  That is amazing !

One must wonder how long exposure to Mathematica allow one to have that 
kind of insight demonstrated here.    It is time for me to read on some 
serious Statistics` :)

My humble trials used to end like this:
FindFit::cvmit: Failed to converge to the requested accuracy or 
precision \
within 10000000 iterations

Old Hungarian proverb:  "More with brain than muscle".  I do not give 
up on hope :)

Thanks you all who responded.  I learned a lot.

Ray, thanks again.

János

------------------------------------------------
``Our enemies are innovative and resourceful, and so are we. They never 
stop thinking about new ways to harm our country and our people, and 
neither do we.''       -- George W. Bush


  • Prev by Date: Re: Re: How to reprensent the result in vector form?
  • Next by Date: Re: MovieParametericPlot-3D
  • Previous by thread: Re: Fitting question
  • Next by thread: Mathematica -> TeX