[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LMFIT -- stay away from it!

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