Questions tagged [lmfit]

lmfit is a Python library for Least-Squares Minimization with Bounds and Constraints.

A library for least-squares minimization and data fitting in Python. Built on top of scipy.optimize, lmfit provides a Parameter object which can be set as fixed or free, can have upper and/or lower bounds, or can be written in terms of algebraic constraints of other Parameters. The user writes a function to be minimized as a function of these Parameters, and the scipy.optimize methods are used to find the optimal values for the Parameters. The Levenberg-Marquardt (leastsq) is the default minimization algorithm, and provides estimated standard errors and correlations between varied Parameters. Other minimization methods, including Nelder-Mead’s downhill simplex, Powell’s method, BFGS, Sequential Least Squares, and others are also supported. Bounds and contraints can be placed on Parameters for all of these methods.

https://pypi.python.org/pypi/lmfit

382 questions
0
votes
2 answers

Python LMFIT restriction fit parameters

I'm trying to fit a function to some data in Python using the LMFIT library for nonlinear functions. It's easy enough, but I want to know if there's a way to restrict some properties of the fitted values. For example, in the following code I fit my…
Liz Salander
  • 321
  • 3
  • 14
0
votes
1 answer

Different constraints for fit parameter in lmfit model

I am trying to create a multible voigt/Gaussian/Lorentizan-peak fit function with lmfit. Therefore, I wrote the following Function: def…
Matthias K
  • 93
  • 9
0
votes
1 answer

LMFIT - Extrackt variables form Fitfunction

i wrote a short code to fit spectra from optical emission spec.. Therefor I fitted a VoigtModel into the Peak and LinearModel into the backgrund. Someting like this: mod=VoigtModel() pars = mod.guess(y, x=x) out = mod.fit(y, pars, x=x)` and…
0
votes
1 answer

confusing error when using minimize of lmfit in python

my code is as following: import numpy as np from math import * from scipy.optimize import * import scipy.optimize as opt from lmfit import Minimizer, Parameters, report_fit import lmfit as lf f = open('data.txt','r') lines=f.readlines() …
jing li
  • 43
  • 3
0
votes
1 answer

lmfit minimize weighting initial data

I am fairly new to python and I am trying to do some curve fitting using lmfit. The code works pretty well but I would like to force the fit through the origin (0,0). I've seen here in stakoverlow that using "curve_fit" you can add and attribute…
0
votes
2 answers

How to fit data with two set of independent variables

i have this equation a*(t^alpha)*(p_p^beta) that i want to fit to get the alpha and beta values where t and p_p are the independent variables. My questions is how do i write the final fit model (result) expression. result = model.fit(S_L1, params,…
user9259974
0
votes
0 answers

Surprising results obtained using lmfit minimize default minimization method

I am using lmfit to look for the parameters that optimize the fit of a model to molecular spectra. The residual program invokes a Fortran code that computes the energy level and matches them with the available experimental data, providing the set of…
Currix
  • 95
  • 9
0
votes
1 answer

Lmfit gives -1 correlation and large uncertainty (python)

I am trying to fit a model function to a curve using the lmfit module. The curve that I am fitting is set up as follows: e(x) = exp(-(x-X)/x0) for x larger or equal than X, 0 otherwise. G(x) = (1/sqrt(2*pi)*sigma) * exp(-x^2/2*sigma^2) The model fit…
ksh
  • 23
  • 5
0
votes
1 answer

Parameters undefined using lmfit

I am trying to fit a curve to the equation below with the given data. The equation is Rate=k*Concentration^n. I am having trouble as the n when fitted is -6, which is not possible so I am trying to set a bound at min=0. However, I am getting a…
0
votes
1 answer

Extending plotting

I have the following code for my theoretical analysis using experimental data. I am trying to fit a curve and extrapolate S_u0 values to determine the initial temperatures. # Determination of laminar burning velocities from experimental data using…
user9259974
0
votes
1 answer

Extending a trendline in a lmfit plot

I have fitted a curve using lmfit but the trendline/curve is short. Please how do I extend the trendline/curve in both directions because the trendline/curve is hanging. Sample codes are warmly welcome my senior programmers. Thanks.
user9259974
0
votes
1 answer

class instance becomes un(dill)pickleable when constraint function and Parameters defined inside class scope

To diagnose a dill unpickling problem with lmfit objects, I wanted to try including my constraint function definition in the class whose instance I would later pickle. However, dumping a dill pickle where the constraint function is defined inside…
PetMetz
  • 75
  • 1
  • 7
0
votes
1 answer

Pythin lmfit library: How do I use the minimizer to limit the # of function calls

How do I use the Minimizer object to minimize the # of function calls. I get this message from the logs: Too many function calls (max set to %i)! Use: minimize(func, params, ..., maxfev=NNN)or set leastsq_kws[\'maxfev\'] to increase this…
im281
  • 455
  • 1
  • 5
  • 14
0
votes
1 answer

Python fitting sinus cardinal and LMFIT library

I have a set of data from a physic experiment (simple-slit experiment) in university and i am trying to fit this data to a model that i build from the lmfit library. I want a sinus cardinal square, in this form: I(X)=…
laplaya
  • 1
  • 1
0
votes
1 answer

Python fit with normalized parameters

If I define fitting function as: def func(a1,a2,a3,a4): return a1*y1+a2*y2+a3*y3+a4*y4 and when i fit I want to tie my parameters: a1**2+a2**2+a3**2+a4**2=1 I cannot find the way to do that with scipy.optimize or lmfit module. Do you have any…