Robert J Tamburo wrote:
> 
> Anyone have any clue about nonlinear curve fitting. I'm trying to implement
> the Levenberg-Marquardt method in C++ from Numerical Recipes in C. I have it
> running, but it doesn't do as well a job as commercial software. Can someone
> suggest any tweaks to this method to make it better or maybe a totally
> different method. By the way, I'm trying to fit this equation: a +
> .5*b*{1+erf[(x-c)/(d*sqrt(2)]}

There is some controversy about Numerical Recipes in general.  For
example, the people at Jet Propulsion Lab say that they simply should
not be used:

        http://math.jpl.nasa.gov/nr/

I myself found a lot of things in the Recipes extremely useful.  (Why
not?  For example in the Fortran version of the book, the TRED2 routine
and several others are exact copies from EISPACK, only the order of
arguments were changed [;)].  The NR code is nevertheless copyrighted. 
Some "software engineering", eh?).  

That said, the Marquardt code in NR is incredibly sloppy.  Over the
years, I tried to fix it several times, just to be able to compare it
with other codes, but always got disgusted very quickly.  It doesn't
even work *on their own test problem* (three gaussians) after you step
away from the initial estimates they gave.  Other codes handle their
test data from modified initial estimates with no problem.

The bottom line, I'd just forget about NR when it comes to Marquardt.

I have a book by J.-G. Reich (1992) "Curve Fitting for Scientists and
Engineers" ISBN-0070517617 which has a C (not C++) code in it that
implements Marquardt with only one error: it forgets to reset the
'Marquardt compromise parameter' to zero on the last iteration.  Now
that you know about the error, you could probably make a C++ class from
the book code with very little effort.  Incredibly, *all* variables in
the book code have global scope, so just make them member variables in a
C++ class.

Hope this helps,

        -- Petr
_____________________________________________________________________
P e t r   K u z m i c,  Ph.D.               mailto:[EMAIL PROTECTED]
BioKin Ltd. * Software and Consulting           http://www.biokin.com
P.O. Box 8336                                        Ph. 608.256.4790
Madison, WI 53708                                    Fax 608.256.1269


=================================================================
Instructions for joining and leaving this list and remarks about
the problem of INAPPROPRIATE MESSAGES are available at
                  http://jse.stat.ncsu.edu/
=================================================================

Reply via email to