[Date Index]
[Thread Index]
[Author Index]
Re: NonlinearFit problem
*To*: mathgroup at smc.vnet.net
*Subject*: [mg52113] Re: NonlinearFit problem
*From*: adam.smith at hillsdale.edu (Adam Smith)
*Date*: Thu, 11 Nov 2004 04:52:19 -0500 (EST)
*References*: <cmnabi$7sn$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Just an observation in addition to those who already mentioned the
problem with the first data point.
Does your function have to be exactly of the form f= r^a Exp[-b r]?
The reason I asked is that in looking at the fit, it appeared to me
that one could obtain a better fit by allowing a "zero offset" in the
first parameter. For example f = (r-c)^a Exp[-b (r-c)]. See the
steps below to produce a comparison graph.
I don't know your purposes for the fit. But if you are fitting to
some measurements, the offset "c" could be reasonable if there was
some uncertainty in establishing the actual zero point for the
measurement.
Adam Smith
In[1]:=
<< Statistics`NonlinearFit`
<<Graphics`Colors`
<<Graphics`Graphics`
In[4]:=
data={{0.0001, 1.00002}, {2.31507, 26.4522}, {4.32033, 56.8265},
{6.63539,
59.6674}, {8.64066, 39.5536}, {10.9557, 21.6862}, {12.961,
10.1456}, {15.276, 4.39652}} ;
myfit = NonlinearFit[data, r^a Exp[-b (r)],r, {a,b} ]
newfit = NonlinearFit[data, (r-c)^a Exp[-b (r-c)],r,
{{a,5.5},{b,1.},{c,0}} ]
In[7]:=
plot1 = Plot[{myfit,newfit},{r,0,16},PlotStyle\[Rule]{Black,Blue}];
In[8]:=
plot2 = ListPlot[data,PlotStyle\[Rule]PointSize[0.02]];
In[9]:=
DisplayTogether[plot1,plot2];
Feng-Yin Chang <fychang at slac.stanford.edu> wrote in message news:<cmnabi$7sn$1 at smc.vnet.net>...
> Hi All,
> Could anyone give me any suggestion for the specified fitting function
> f= r^a Exp[-b r]?
> My data point was given below,
> data={{0, 1.00002}, {2.31507, 26.4522}, {4.32033, 56.8265}, {6.63539,
> 59.6674}, {8.64066, 39.5536}, {10.9557, 21.6862}, {12.961,
> 10.1456}, {15.276, 4.39652}}
>
> The following way,
> NonlinearFit[data,f,r,{a,b}], gives the error message,
> FindFit::njnum:
> The Jacobian is not a matrix of numbers at (a,b)={1.,1.}.
>
> How should I do this fitting without the problem?
>
>
> Feng-Yin Chang,
> Institute of Physics,NCTU,Taiwan
Prev by Date:
**Re: nonlinear programming with differential-algebraic constraints (2)**
Next by Date:
**Solve and Reduce**
Previous by thread:
**Re: Re: NonlinearFit problem**
Next by thread:
**Mathematica Categorization - Humor**
| |