There is a newer version of this record available.

Software Open Access

LMFIT: Non-Linear Least-Square Minimization and Curve-Fitting for Python

Newville, Matthew; Stensitzki, Till; Allen, Daniel B.; Ingargiola, Antonino

Lmfit provides a high-level interface to non-linear optimization and curve fitting problems for Python. Lmfit builds on Levenberg-Marquardt algorithm of scipy.optimize.leastsq(), but also supports most of the optimization method from scipy.optimize.   It has a number of useful enhancements, including:

  •  Using Parameter objects instead of plain floats as variables.  A Parameter has a value that can be varied in the fit, fixed, have upper and/or lower bounds.  It can even have a value that is constrained by an algebraic expression of other Parameter values.
  • Ease of changing fitting algorithms.  Once a fitting model is set up, one can change the fitting algorithm without changing the objective function.
  • Improved estimation of confidence intervals.  While scipy.optimize.leastsq() will automatically calculate uncertainties and correlations from the covariance matrix, lmfit also has functions to explicitly explore parameter space to determine confidence levels even for the most difficult cases.
  • Improved curve-fitting with the Model class.  This which extends the capabilities of scipy.optimize.curve_fit(), allowing you to turn a function that models for your data into a python class that helps you parametrize and fit data with that model.
  •  Many pre-built models for common lineshapes are included and ready to use.

The lmfit package is Free software, using an MIT license

Files (846.7 kB)
Name Size
lmfit-py-0.8.0.tar.gz
md5:64770b567252e8fc255784d348bde3db
846.7 kB Download
970
151
views
downloads
All versions This version
Views 9702,970
Downloads 15159
Data volume 225.3 MB50.0 MB
Unique views 7412,649
Unique downloads 4159

Share

Cite as