MPFIT  Robust nonlinear least squares curve fitting
These IDL routines provide a robust and
relatively fast way to perform leastsquares curve and surface
fitting. The algorithms are translated from MINPACK1, which is a rugged
minimization routine found on Netlib, and distributed with
permission. This algorithm is more desirable than CURVEFIT because it
is generally more stable and less likely to crash than the bruteforce
approach taken by CURVEFIT, which is based upon Numerical
Recipes.
MPFIT has additional capabilities not found in CURVEFIT. Model
parameters can be "frozen" (that is, held constant during the fitting
process). Simple boundary constraints can be imposed on parameter
values, which can be helpful to keep parameters from becoming
negative, for example. Please see the documentation for the PARINFO
keyword if you wish to use this facility.
You can cite MPFIT in your papers! See the FAQ entry on citations for more
information.
A C version of the library is available! See
the special page on the C Version of MPFIT.
NEW! (20111221)
The function MPPROPERR can be used to estimate the uncertainty of your
model function, via standard propagation of error formulae. For
example, if you have a best fit model with parameter uncertainties,
then MPPROPERR can be used to see where these parameter uncertainties
cause the most uncertainty in the model function that is compared to
your data. See the function for more documentation and examples.
Craig's presentation at the IDL Visualize 2009
workshop in Washington DC in April 2009 explains how equation
solving and parameter constraints work. This zip file (MarkwardtMPFITVisualize2009.zip)
contains the presentation as well as example codes relevant to the
talk (the PDF and Powerpoint presentations
are also available separately).
Frequently Asked Questions
There are several files included in the MPFIT package. Not all of
them are required, but you will probably wish to download more than
one. This chart can help you decide
between the choices. I recommend the combination of MPFIT.PRO and
MPFITFUN.PRO as being suitable for most 1dimensional problems.
MPCURVEFIT.PRO is a dropin replacement for IDL's CURVEFIT.PRO, but
with the additional features of the MPFIT family of functions.
You can download the entire MPFIT package as a gzip'ed tar file or zip
file.
Statistical Tests  Hypothesis Testing and Confidence Interval Estimation for Chisquare, F, and Normal Distributions
The following functions perform statistical tests and estimate
confidence limits. MPCHITEST, MPFTEST and MPNORMTEST are useful for
hypothesis testing for variables distributed as the chisquare, F, and
normal distributions. The F distribution is used in testing ratios of
variances and for addition of parameters in chi square fitting. MPCHILIM
and MPNORMLIM estimate confidence limits for chisquare and normal
distributions.
These functions are based on the CEPHES library of special
functions by Stephen Moshier, available from Netlib, and do not depend on
any special function implementations from IDL.
Likelihoods  Alternate likelihood functions
When fitting a linear model to data with errors in both X and Y,
the standard leastsquares likelihood function is not appropriate,
since it considers only errors in Y. LINFITEX is an alternate
likelihood function for fitting a linear model to data with errors in
both X and Y, based on Numerical Recipes by Press et al. You
use it as your model function with MPFIT (not MPFITFUN), and specify
the data values using the FUNCTARGS keyword. Please see the
documentation within the module for more information and examples of
how to use it.
Peak Fitting  Specialized Peak and Ellipse Fitting Applications
These are a few specialized fitting applications which use the
MPFIT library of routines. The functions MPFITPEAK and MPFIT2DPEAK
replace the builtin IDL functions GAUSSFIT and GAUSS2DFIT.
The function MPFITELLIPSE is used to fit an elliptical shape to a
set of XY scatter points. Users should still consult the ODRPack Page which is more general
and robust for these types of problems, however MPFITELLIPSE is good
for quick and dirty problems where the measurement error is small
compared to the ellipse axes.
These functions are distinguished in several ways. First, they use
the MPFIT library, and so the fitting should be more robust. That
also means you can use the PARINFO keyword to hold parameters
constant, etc. Second, I use a different technique to estimate the
starting parameter values, which I think will be more robust under
more circumstances.
Finally, for the peak fitters, you are not limited to a Gaussian
function; the Lorentzian and Moffat peaks are available as well. [ The
Moffat function is a modified Lorentzian with variable power law
index. (Moffat, A. F. J. 1969, Astronomy & Astrophysics, v. 3,
p. 455461). ] However, you may notice that the fitting process is
slower. That is simply the nature of MPFIT  it is definitely more
compute intensive.
TNMIN  Nonlinear optimization
TNMIN is a general nonlinear function minimizer based on a
truncatedNewton method by Stephen Nash. TNMIN will minimize any
function that can be expressed in IDL. TNMIN can use
explicitlycalculated partial derivatives, or estimate them
numerically.
TNMIN has all of the enhancements that MPFIT
has, including the ability to fix parameters, to place simple bounds
on parameters, and to tie one parameter value to other parameter
values. Both MPFIT and TNMIN share same PARINFO keyword mechanism to
enable this feature.
MPFIT is still recommended for curve fitting applications, but
TNMIN will be useful when general minimization is desired.
