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

Matt Newville newville at cars.uchicago.edu
Fri Nov 4 13:27:42 EDT 2016


Alexandre,



On Fri, Nov 4, 2016 at 12:13 PM, Alexandre Furlan <
alexandrepfurlan at gmail.com> wrote:

>
> ---------- Forwarded message ----------
> From: Alexandre Furlan <alexandrepfurlan at gmail.com>
> Date: 2016-11-04 14:59 GMT-02:00
> Subject: using curve_fit with a fixed parameter
> To: scipy-user at 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
>
>

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20161104/6b77f3a3/attachment.html>


More information about the SciPy-User mailing list