Quantcast

[SciPy-User] Fwd: using curve_fit with a fixed parameter

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[SciPy-User] Fwd: using curve_fit with a fixed parameter

Alexandre Furlan

---------- Forwarded message ----------
From: Alexandre Furlan <[hidden email]>
Date: 2016-11-04 14:59 GMT-02:00
Subject: using curve_fit with a fixed parameter
To: [hidden email]


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
 


_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fwd: using curve_fit with a fixed parameter

Matt Newville
Alexandre,



On Fri, Nov 4, 2016 at 12:13 PM, Alexandre Furlan <[hidden email]> wrote:

---------- Forwarded message ----------
From: Alexandre Furlan <[hidden email]>
Date: 2016-11-04 14:59 GMT-02:00
Subject: using curve_fit with a fixed parameter
To: [hidden email]


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
 

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

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.scipy.org/mailman/listinfo/scipy-user
Loading...