MathGroup Archive 2005

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

Search the Archive

Re: FinFit question

  • To: mathgroup at
  • Subject: [mg54853] Re: FinFit question
  • From: Kevin <kmccann at>
  • Date: Fri, 4 Mar 2005 05:07:48 -0500 (EST)
  • Organization: University of Maryland, Baltimore County
  • References: <d060ku$koc$>
  • Sender: owner-wri-mathgroup at

I suspect the cause of your problem is that the parameter search in
NonlinearFit has been changed in 5.0, and now allows Ro to be sampled in
the negative range, which results in a complex result.

Here is what I did:

f[B_, Ro_, x_] := B/Log[x/Ro]

lsFit[B_, Ro_] :=
   Plus @@ Apply[
     (Re[f[B, Ro, #1] - #2])^2 & ,
     points, 1]

sol = FindMinimum[lsFit[B, Ro], {B, 1000}, {Ro, .01}][[2]]

I get:

B = 4021.058892362411
Ro = 0.009479542538875833

with residual: 0.000958775

My first try did not have the Re[] in the lsFit definition; however, I
found that I ran into the same complex problem that you had in the
search. So, I modified the function to accomodate, and then checked to
ensure that the final result was a real function over the range of
points. This flexibility is why I always roll my own LSQ fit.



Zsolt Reg=E1ly wrote:

> Hi
> I have used Mathematica 4.2 to solve this problem
>     points = {{23400, 273.2}, {6800, 298.2}, {2400, 323.2}};
>     T[R_] = NonlinearFit[points, B/Log[R/Ro], {R}, {B, Ro}];
> wihich gives the result as
>     4021.05/Log[105.49 R]
> That is a good result, but when I try to do the same in Mathematica 5.0
> I get error messaeges and an other solutions, which is surely bad
>     1556.90/Log[-0.014 R]
> Why doesn't work FindFit for this function in Mathematica 5.0
> Regards,
> Zsolt Regaly (zs.regaly at

  • Prev by Date: Re: Rearranging a data array containing calendrical as well as data entries.
  • Next by Date: Re: Rearranging a data array containing calendrical as well as data entries.
  • Previous by thread: Re: FinFit question
  • Next by thread: Re: FinFit question