LMFIT -- stay away from it! [message #10942] |
Sat, 31 January 1998 00:00  |
Wayne Landsman
Messages: 117 Registered: January 1997
|
Senior Member |
|
|
A while back I posted a complaint about LMFIT, the IDL implemention of
the Numerical Recipes version of the Levenberg-Marquardt non-linear
least-squares algorithm. I complained that the form of the
user-supplied function was different and less flexible than that of
CURVEFIT. In fact, there is a more fundamental problem with LMFIT.
Although the documentation says that the user-supplied function should
accept a vector argument, **only scalar arguments are ever passed to the
user-supplied function**! Thus, if one is fitting a function of 2000
points, then there must be 2000 calls to the user-supplied function on
each iteration. And thus with a computationally intensive function,
LMFIT will be about 2000 times slower than fitting with CURVEFIT.
The same problem occurs in the IDL implementation of the Numerical
Recipes routines QSIMP. But the problem is more disatrous in LMFIT,
which requires more iterations and partial derivative computations.
My advice -- forget about LMFIT, and stick with CURVEFIT (or write your
own implementation of the Numerical Recipes routine).
--Wayne Landsman landsman@mpb.gsfc.nasa.gov
|
|
|
Re: LMFIT [message #18190 is a reply to message #10942] |
Mon, 13 December 1999 00:00  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
"Alberto Verga" <verga@marius.univ-mrs.fr> writes:
> I tried the following example on the use of LMFIT given in the IDL 5.2
> help:
>
> ...example removed...
>
> I obtained
> % LMFIT: Warning: Failed to Converge.
>
> and in consequence a bad fit!
> Does anyone known if this LMFIT is correctly implemented?
"Correct" is a matter of debate. Designing an algorithm for curve
fitting appears to be as much art as it is science. The procedures
supplied by IDL are somewhat of a mixed bag:
CURVEFIT - quick and dirty. Quick because it runs fast. Dirty,
perhaps, because it doesn't always converge. The best if
judged in EASY and SPEED categories.
LMFIT - slow and dirty. Slow because function calls are done in FOR
loops (astounding!). If there are convergence problems, it's
probably because LMFIT is based on Numerical Recipes.
I recommend you try MPFIT and related functions (web page below). I
have translated these from the original MINPACK-1 package, which was
designed by a real numerical analyst! I value reliability more than
absolute speed and was willing to make a compromise.
I have found the results to be very reliable in my own work, and I
have gotten similar comments from other researchers. For your
application I clearly recommend MPFIT and the driver function
MPFITFUN.
Craig
http://cow.physics.wisc.edu/~craigm/idl/idl.html
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|