Re: FindFit issue
- To: mathgroup at smc.vnet.net
- Subject: [mg86422] Re: [mg86395] FindFit issue
- From: Darren Glosemeyer <darreng at wolfram.com>
- Date: Tue, 11 Mar 2008 02:56:56 -0500 (EST)
- References: <200803100704.CAA24763@smc.vnet.net>
t.dubaj at gmail.com wrote: > Hi, > I am trying to fit experimental data > > d = {{1000, 44.576*10^(-3)}, > {600, 49.546*10^(-3)}, > {800, 46.757*10^(-3)}, > {400, 55.023*10^(-3)}, > {200, 61.209*10^(-3)}, > {10, 71.584*10^(-3)}, > {100, 65.367*10^(-3)}} > > and model is: > > y = 0.072214 - a*Log[10, 1+b*x] > > but Mathematica after typing > > FindFit[d, 0.072214 - a*Log[10, 1 + b*x], {a, b}, x] > > return > > FindFit::nrlnum: The function value {-0.0226973-0.0208168 \ > \[ImaginaryI],<<5>>,-0.0282009-<<21>> \[ImaginaryI]} is not a list of > \ > real numbers with dimensions {7} at {a,b} = {0.0152574,-1.99204}. > > {a -> 0.0152574, b -> -1.99204} > > (especialy value of "b" is really awful - negative number in Log) > > But I know, there is Fit (calculated in Scientist) with coefficients > a = 0.033706 > b = 0.0057934 > > Can someone explain what I'm doing wrong? > > Best regards, > > T.D. > > > To obtain a good fit, non-default starting values are needed for the parameters. By default 1 is used as the starting value for each parameter if no starting value is given. In this case, the default starting values are pretty far off from the optimal values, as can be seen by looking at Show[ListPlot[d, PlotMarkers -> Automatic], Plot[0.072214 - Log[10, 1 + x], {x, 10, 1000}], PlotRange -> All] With better starting values, a good fit is obtained. In[1]:= d = {{1000, 44.576*10^(-3)}, {600, 49.546*10^(-3)}, {800, 46.757*10^(-3)}, {400, 55.023*10^(-3)}, {200, 61.209*10^(-3)}, {10, 71.584*10^(-3)}, {100, 65.367*10^(-3)}} Out[1]= {{1000, 0.044576}, {600, 0.049546}, {800, 0.046757}, {400, 0.055023}, > {200, 0.061209}, {10, 0.071584}, {100, 0.065367}} In[2]:= ff = FindFit[d, 0.072214 - a*Log[10, 1 + b*x], {{a, .1}, {b, .01}}, x] Out[2]= {a -> 0.0337413, b -> 0.00578092} In[3]:= scientist = {a -> 0.033706, b -> 0.0057934} Out[3]= {a -> 0.033706, b -> 0.0057934} FindFit has a slightly better fit (smaller sum of squared errors) than the quoted result. This may just be an indication of a difference in the tolerances used by the two applications. In[4]:= Total[((0.072214 - a*Log[10, 1 + b*x] /. ff /. x -> d[[All, 1]]) - d[[All, 2]])^2] -7 Out[4]= 9.81295 10 In[5]:= Total[((0.072214 - a*Log[10, 1 + b*x] /. scientist /. x -> d[[All, 1]]) - d[[All, 2]])^2] -7 Out[5]= 9.81367 10 Darren Glosemeyer Wolfram Research
- References:
- FindFit issue
- From: t.dubaj@gmail.com
- FindFit issue