Skip to main content
QUICK REVIEW

[Paper Review] Non-linear Least Squares Fitting in IDL with MPFIT

C. B. Markwardt|ArXiv.org|Feb 17, 2009
Neural Networks and ApplicationsComputer Science1 references337 citations
TL;DR

This paper presents MPFIT, a robust and optimized implementation of non-linear least squares fitting in IDL, derived from the MINPACK-1 FORTRAN library. It enhances performance, supports parameter constraints, error estimation, and diagnostic tools, and has been widely adopted in astronomy and scientific computing, with translations into Python and C for broader use.

ABSTRACT

MPFIT is a port to IDL of the non-linear least squares fitting program MINPACK-1. MPFIT inherits the robustness of the original FORTRAN version of MINPACK-1, but is optimized for performance and convenience in IDL. In addition to the main fitting engine, MPFIT, several specialized functions are provided to fit 1-D curves and 2-D images; 1-D and 2-D peaks; and interactive fitting from the IDL command line. Several constraints can be applied to model parameters, including fixed constraints, simple bounding constraints, and "tying" the value to another parameter. Several data weighting methods are allowed, and the parameter covariance matrix is computed. Extensive diagnostic capabilities are available during the fit, via a call-back subroutine, and after the fit is complete. Several different forms of documentation are provided, including a tutorial, reference pages, and frequently asked questions. The package has been translated to C and Python as well. The full IDL and C packages can be found at http://purl.com/net/mpfit

Motivation & Objective

  • To address the limitations of built-in IDL fitting routines like CURVEFIT and LMFIT, which are unreliable and underutilize vectorization.
  • To port the robust MINPACK-1 non-linear least squares algorithm to IDL while preserving numerical stability and performance.
  • To extend the core algorithm with user-friendly features such as parameter constraints, automatic Jacobian estimation, and diagnostic feedback.
  • To provide a modular, extensible framework for fitting 1D curves, 2D images, peaks, and interactive fitting in IDL.
  • To enable cross-language adoption by creating equivalent C and Python versions, ensuring broad scientific utility.

Proposed method

  • Translating the MINPACK-1 FORTRAN library into IDL to retain its numerical robustness and convergence properties.
  • Implementing MPFIT as a generic fitting engine that supports arbitrary data dimensionality and weighting schemes.
  • Introducing the PARINFO structure to manage parameter constraints, including fixed, bounded, and tied parameters.
  • Enabling user-defined or numerically estimated Jacobians via AUTODERIVATIVE and PARINFO settings, with configurable step sizes.
  • Adding callback routines (ITERPROC) and external evaluation support for complex or slow-to-compute functions.
  • Computing the parameter covariance matrix and error estimates post-fit, improving statistical inference.

Experimental results

Research questions

  • RQ1How can a non-linear least squares fitting engine be made both robust and efficient in IDL, given the limitations of existing built-in routines?
  • RQ2What enhancements are necessary to support common astronomical fitting needs such as parameter constraints and error estimation?
  • RQ3How can the MINPACK-1 algorithm be adapted to IDL’s syntax and performance model without sacrificing numerical accuracy?
  • RQ4What role do diagnostic callbacks and external evaluation play in enabling fitting of computationally intensive models?
  • RQ5To what extent can a single IDL-based fitting package be successfully ported to Python and C while preserving functionality and usability?

Key findings

  • MPFIT has been downloaded several thousand times over ten years and is widely used in astronomical and scientific computing applications.
  • The package has been cited in at least 29 refereed publications and 102 preprints on arXiv since 2001, demonstrating broad academic impact.
  • MPFIT has been successfully translated into Python and C, with the Python version integrated into the SciPy scientific library.
  • The C version provides high performance and portability while retaining IDL-based enhancements such as constraint handling and diagnostics.
  • MPFIT has been incorporated into standalone scientific packages like PAN for neutron scattering and PintOfAle for X-ray spectroscopy.
  • The package supports advanced features such as parameter covariance matrix computation, error handling, and iterative diagnostics, significantly improving usability over base MINPACK-1.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.