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
1 answer

Trouble with curve fitting - lmfit won't produce proper fit to peak data

I'm quite new to python and the lmfit model and having some trouble. I want to fit a peak function (something like Gaussian or Voigtian profil) to my experimental data, but it never gives me any good results. Its best fit is a linear function, which…
kire
  • 95
  • 2
  • 12
0
votes
1 answer

confidence interval for the data itself using lmfit in python

Here is the link for the LMFIT implementation of the confidence intervals of parameters: http://lmfit.github.io/lmfit-py/confidence.html Here is the code I am using: import lmfit import numpy as np # x = np.linspace(1, 10, 250) #…
bazilevs31
  • 99
  • 6
0
votes
1 answer

How to fit data with missing data point in lmfit minimize?

For example I have data: x y1 y2 y1 --------------------- 1 5 8 - 2 4 - 4 3 7 7 10 4 9 4 12 5 10 - 20 6 15 - 21 Where x is x axis and y1, y2, y3 are three different data sets, which…
Dancia
  • 762
  • 1
  • 18
  • 32
0
votes
1 answer

Implementation of Stata's "nl" package (nonlinear least squares) in Python

Does anybody know if there is an implementation of the Stata nl (nonlinear least squares) package in Python? I tried to use lmfit as well as optimize.leastsq from scipy, but both do not seem to work. The equation for the regression is Y = x1 + b1 +…
0
votes
1 answer

python lmfit: Given an array of discrete values that define a model, how to fit a same length array of data with specified uncertainty values?

I have a dataset and uncertainty both single arrays of length 100. I have a "model" array also of length 100. Goal: Optimize only one parameter (scaling the amplitude) of this model array to better fit the data given its uncertainty. so far I've…
Arya
  • 189
  • 4
  • 17
0
votes
1 answer

lmfit not performing as expected

I'm writing a script that is going to be used to fit some photoluminescence spectra with custom models and after creating a script using SciPy I learned that setting bounds on the fitting parameters is much easier if lmfit…
0
votes
1 answer

Fit several functions with lmfit with shared parameters, no datasets- in Python

I would like to find the parameters E_u, tau_max, and G from these 3 functions. The functions are the following: Function 1: 0=0.009000900090009*E_u*(0.000103939092728486*exp(1500000.0/tau_max) + 0.000157703794137242*exp(2999000.0/tau_max) +…
Sally
  • 1
  • 1
0
votes
2 answers

curve fitting with lmfit python

I am new to python and trying to fit data using lmfit. I am following on the lmfit tutorial here: http://lmfit.github.io/lmfit-py/parameters.html and this is my code (based on the code explained in the above link): import numpy as np import…
A.E
  • 997
  • 1
  • 16
  • 33
0
votes
1 answer

lmfit: maximum recursion depth exceeded

I'm using lmfit to fit a "complex" model onto experimental data. I define the parameters of the model like this: def model(t, y0, h, A1, x1, s1, A2, x2, s2, A3, x3, s3, A4, x4, s4): y = y0 + h * ( A1 * (0.5 + 0.5 *…
JPFrancoia
  • 4,866
  • 10
  • 43
  • 73
0
votes
1 answer

importing lmfit succesfull but importing Model from lmfit not

I have installed lmfit trough PIP pip install lmfit==0.7.2 importing lmfit in ipython notebook seems to work. That is, the import does not give any error messages and I can call a bunch of functions from lmfit. However when i try to import Model…
Adriaan Rol
  • 420
  • 2
  • 4
  • 12
0
votes
1 answer

fitting data to 2D function using lmfit in python

I wish to fitting data with a 2D function in order to extract parameter (a) and (b) using lmfit package. Basically as a 1D function fitting, I am trying to fit every data point to the 2D function at the same coordinates (x,y). This is mean that…
user3395817
  • 23
  • 1
  • 6
0
votes
1 answer

lmfit -py using arrays for parameter optimization

Situation: I'm trying to optimise parameters for a natural creek where gases degas or ingas at a certain rate according to reasonably well established equations. We have the measured concentrations at certain distances downstream and would like to…
Oregano
  • 134
  • 2
  • 12
-1
votes
1 answer

LMFIT vs. Scipy Why am I getting different results in minimize

In short, I have data I'm trying to fit, and LMFIT and Scipy give 2 different solutions, with LMFIT being significantly worse. Just some detail as to what is going on: The "model" is a population weighted average. The "populations" are derived from…
samman
  • 559
  • 10
  • 29
-1
votes
1 answer

Why am i getting a straight line for exponential decay curve best-fit

Hi all, I am trying to fit a curve of a double exponential decay function in Python. The code I have used is as follows. I am not sure why I am getting a straight line for the fit. I welcome any help and suggestions to my code, it would be of great…
Angela Mary
  • 49
  • 1
  • 8
-1
votes
2 answers

How to fit a Gaussian into my data (csv) file using Python

I have collated the data and have it in CSV.format. I wish to fit a Gaussian into my data using Python. Can someone help me with the starting steps? I have gone through the lmfit. documentation from Python. I'm not very sure how to go about it.
Angela Mary
  • 49
  • 1
  • 8
1 2 3
25
26