Coyote's Guide to IDL Programming

Flexible Curve Fitting in IDL

QUESTION: Joseph Stuart from MIT asked this question in a recent IDL newsgroup article:

I'm using curvefit to fit a function with a bunch of parameters to a dataset. I'd like to be able to easily specify that some parameters should be held constant on a particular run, while others are fit. I want to do this to explore how well the curvefit is going and to explore the parameter space. The only way I've come up with so far to do this is using commons blocks as below. If you can think of another way to do this, let me know. I'd like to avoid common blocks on aesthetic grounds, but there doesn't seem to be any other way to pass extra information to the function that curvefit calls.

ANSWER: Craig B. Markwardt (craigm@pcasun3.gsfc.nasa.gov) answered this way, and I agree completely.

May I recommend that you try MPFIT:

   http://cow.physics.wisc.edu/~craigm/idl

MPFIT is a Levenberg-Marquardt fitter, translated from the FORTRAN MINPACK-1 sources available on netlib. I have generally found this fitter to be quite robust. So far, no complaints from the net either!

MPFIT allows you to easily hold parameters fixed (or not). Investigate the documented PARINFO keyword, and also the tutorial page accessible from the above page, for more information. In addition, MPFIT allows you to put lower and upper bounds on parameter values.

Using MPFIT is easy. If you use MPFITFUN, you supply a function which computes the "model" function, including vector functions, and of course your data. MPFIT computes LM derivatives numerically, saving you from the trouble of doing it yourself. Fitting two- or three-dimensional data is just as easy.

Google
 
Web Coyote's Guide to IDL Programming