Discussion:
[SciPy-User] Fwd: using curve_fit with a fixed parameter
Alexandre Furlan
2016-11-04 17:13:26 UTC
Permalink
---------- Forwarded message ----------
From: Alexandre Furlan <***@gmail.com>
Date: 2016-11-04 14:59 GMT-02:00
Subject: using curve_fit with a fixed parameter
To: scipy-***@scipy.org


Hi all,

I need to make a least square method of a model function, but a parameter
of my
model function is fixed (I don't change it). I my case, I have :

def func(i,rij,eps,sigma) :

where, i is similar "x", rij is a array used to obtain some parameters of
the function, and
eps and sigma are parameter that I want to optimize. I order to optimize
these parameters I'm doing :

for i in arange(len(rij)/natoms) :
popt,pcov = curve_fit(LJ(i,rij,eps,sigma), x,Ek)

where x = x[i] and Ek[i]. When make it, I have :

TypeError('{!r} is not a Python function'.format(func))
TypeError: -0.019566048015813797 is not a Python function

Do you known how to do this type of optmization using curve_fit ?

many thanks for all

Best

Alexandre
Matt Newville
2016-11-04 17:27:42 UTC
Permalink
Alexandre,



On Fri, Nov 4, 2016 at 12:13 PM, Alexandre Furlan <
Post by Alexandre Furlan
---------- Forwarded message ----------
Date: 2016-11-04 14:59 GMT-02:00
Subject: using curve_fit with a fixed parameter
Hi all,
I need to make a least square method of a model function, but a parameter
of my
where, i is similar "x", rij is a array used to obtain some parameters of
the function, and
eps and sigma are parameter that I want to optimize. I order to optimize
popt,pcov = curve_fit(LJ(i,rij,eps,sigma), x,Ek)
TypeError('{!r} is not a Python function'.format(func))
TypeError: -0.019566048015813797 is not a Python function
Do you known how to do this type of optmization using curve_fit ?
many thanks for all
Best
Alexandre
You might find lmfit useful. It's a wrapper around many of the
scipy.optimize functions to use Parameter objects that can be fixed,
bounded, or constrained, and has many features and classes for data fitting
problems.

https://lmfit.github.io/lmfit-py/

--Matt Newville

Loading...