MathGroup Archive 2008

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

Search the Archive

Re: FindFit issue

  • To: mathgroup at smc.vnet.net
  • Subject: [mg86406] Re: FindFit issue
  • From: Antti Penttilä@smc.vnet.net
  • Date: Tue, 11 Mar 2008 02:53:55 -0500 (EST)
  • Organization: University of Helsinki
  • References: <fr2mhj$o5h$1@smc.vnet.net>

Hi,

With a little help FindFit will find the right solution:

FindFit[d, {0.072214 - a*Log[10, 1 + b*x], b > 0}, {{a, 0.05}, {b, 
0.01}}, x]

return
{a -> 0.0340109, b -> 0.00568993}

With a nonlinear model it's probably best if you try first to bracket 
the parameter values near the optimal by e.g. plotting the solution and 
the data and then give these parameter values as a starting parameters 
for FindFit.

There are a couple of different optimization routines in Mathematica. 
NMinimize is probably better in finding the global optimum. If you write 
out the squared residual sum between your model and data as a function 
(mfun in my example below), and minimize that you get the right solution 
without specifying starting values:

NMinimize[ {mfun, b > 0}, {a, b}]

return
{9.81295*10^-7, {a -> 0.0337413, b -> 0.00578092}}

Antti


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.
> 
> 
> 


  • Prev by Date: Re: How to use Thread when second argument to function is a list
  • Next by Date: Re: Evaluating notebooks from other notebooks
  • Previous by thread: Re: FindFit issue
  • Next by thread: Re: FindFit issue