Markwardt IDL Page

What's New

Programs
   Curve Fitting
   Fitting Tutorial
   Introspection
   Save Files
   Array/Set
   Printing
   Graphics
   Mathematics
   Ephemeris/Timing
   Input/Output
   Miscellaneous
   Full Listing
   Documentation

Google

Markwardt IDL Pages
Entire Web

Craig's techie blog.

Home Page of Craig Markwardt



 


IDL Curve Fitting and Function Optimization





MPFIT - Robust non-linear least squares curve fitting

These IDL routines provide a robust and relatively fast way to perform least-squares curve and surface fitting. The algorithms are translated from MINPACK-1, 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 brute-force 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.

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 1-dimensional problems.

Mar 29 2008115 kb mpfit.proREQUIRED  
Dec 17 200729 kb mpfitfun.proRecommended (1D)  
Dec 17 200726 kb mpfit2dfun.proRecommended (2D)  
Dec 17 200731 kb mpfitexpr.pro  

MPCURVEFIT.PRO is a drop-in replacement for IDL's CURVEFIT.PRO, but with the additional features of the MPFIT family of functions.

Nov 24 200624 kb mpcurvefit.pro  

You can download the entire MPFIT package as a gzip'ed tar file or zip file.

Mar 29 2008130 kb mpfit.tar.gz  
Mar 29 2008171 kb mpfit.zip  
Jan 31 20003 kb MPREADMEGeneral Documentation  
Dec 06 20031 kb INSTALLInstallation Instructions  

Statistical Tests - Hypothesis Testing and Confidence Interval Estimation for Chi-square, 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 chi-square, 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 chi-square 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.

Nov 24 20067 kb mpchitest.proChi-square  
Nov 24 200615 kb mpchilim.proChi-square  
Nov 24 200614 kb mpftest.proF distribution  
Nov 24 20068 kb mpnormtest.proNormal  
Nov 24 20068 kb mpnormlim.proNormal  

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 built-in IDL functions GAUSSFIT and GAUSS2DFIT.

The function MPFITELLIPSE is used to fit an elliptical shape to a set of X-Y 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. 455-461). ] However, you may notice that the fitting process is slower. That is simply the nature of MPFIT -- it is definitely more compute intensive.

Dec 17 200716 kb mpfitpeak.pro1D Gaussian  
Dec 17 200717 kb mpfit2dpeak.pro2D Gaussian  
Mar 29 2008115 kb mpfit.proREQUIRED  
Dec 17 200729 kb mpfitfun.proREQUIRED  
Dec 17 200726 kb mpfit2dfun.proREQUIRED  
Mar 29 200811 kb mpfitellipse.pro  

TNMIN - Non-linear optimization

TNMIN is a general non-linear function minimizer based on a truncated-Newton method by Stephen Nash. TNMIN will minimize any function that can be expressed in IDL. TNMIN can use explicitly-calculated 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.

Dec 17 200769 kb tnmin.pro  


Copyright © 1997-2004 Craig B. Markwardt
Last Modified on 2008-03-29 14:20:14 by Craig Markwardt