       Re: Fitting question

• To: mathgroup at smc.vnet.net
• Subject: [mg51597] Re: [mg51585] Fitting question
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Wed, 27 Oct 2004 01:53:57 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Use NonlinearFit

Needs["Statistics`NonlinearFit`"];

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

f[x_] := Evaluate[
NonlinearFit[totpergen,
a*E^(-c*x)/(b+E^(-c*x))^2,
x, {a,b,c}]];

DisplayTogether[
Plot[f[x], {x,1,Length[totpergen]},
PlotStyle->Blue,
PlotRange->All,
Frame->True, Axes->False],
ListPlot[totpergen,
PlotStyle->Red]];

Bob Hanlon

>
> From: János <janos.lobb at yale.edu>
To: mathgroup at smc.vnet.net
> Date: 2004/10/23 Sat AM 12:22:57 EDT
> To: mathgroup at smc.vnet.net
> Subject: [mg51597] [mg51585] Fitting question
>
> 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:=
> 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:=
> 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.   Looking the ListPlot of runtotpergen, it looks
> similar to the sigmoid function, so I define:
> In:=
> sg[x_] := 1/(1 + E^(-x))
>
> and
> In:=
> dsg = Derivative[sg]
>
> The best I could come out with manual try was:
>
> In:=
> dsgfit = Fit[totpergen,
>     {dsg[0.48*(x - 11)]}, x]
> Out=
> 44143.063409020484/
>    (E^(0.48*(-11 + x))*
>     (1 + E^(-0.48*(-11 + x)))^
>      2)
>
> When I create the plots of the data totpergen and the above Fit dsgfit
> as:
>
> In:=
> lsp = ListPlot[totpergen,
>     PlotRange -> All]
> In:=
> psp = Plot[dsgfit, {x, 1, 25}]
>
> and plot them together, they overlap to some degree, but not to my
> satisfaction.
>
> In:=
> Show[lsp, psp]
>
> totpergen is not symmetrical, so I tried different multiplications of
> x^n and dsg without any success.  I also tried the polynomials of dsg
> like:
>
> In:=
> polydsgfit = Fit[totpergen,
>     {1, dsg[x - 11],
>      dsg[x - 11]^2,
>      dsg[x - 11]^3,
>      dsg[x - 11]^4}, x]
>
> but it just looks funny.
>
> I also tried:
>
> In:=
> paramdsgfit = FindFit[
>     totpergen,
>     a*dsg[b*x - c] + d,
>     {a, b, c, d}, x]
> Out=
> {a -> -2250.9485483974095,
>    b -> -14745.171180125675,
>    c -> 111324.17194273268,
>    d -> 3443.48}
>
> but it gave me just a horizontal line when I plotted it.
>
> In:=
> ip = InterpolatingPolynomial[
>     totpergen, x]
>
> does not help either.
> I feel that Mathematica has the capability to find the best fitting
> function without too much manual trials.    Any hint how to do that ?
>
>
> János
> ----------------------------------------------
> Trying to argue with a politician is like lifting up the head of a
> corpse.
> (S. Lem: His Master Voice)
>
>

```

• Prev by Date: matrix switching Markov sequence
• Next by Date: MovieParametericPlot-3D
• Previous by thread: Re: Fitting question
• Next by thread: Re: Fitting question