[SciPy-User] How to fix a parameter when using curve_fit ?

1,337 views
Skip to first unread message

Spark Liang

unread,
Jun 10, 2011, 8:01:24 AM6/10/11
to scipy...@scipy.org
Hi, would someone be so kind to tell me how to fix some parameters when using curve_fit ?
I googled it and found that I may use scipy.odr or mpfit, but they seem rather complicated.
I also searched the maillist, someone said it can be done by by writing a nested function or a class. but how to do it?

josef...@gmail.com

unread,
Jun 10, 2011, 8:35:27 AM6/10/11
to SciPy Users List

a full version is at http://docs.python.org/library/functools.html in
the example for functools.partial

I usually prefer to use a class, where you set the fixed parameters in
the __init__ and access it with self.a(ttributename) inside the
function.

Josef

>
> _______________________________________________
> SciPy-User mailing list
> SciPy...@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
_______________________________________________
SciPy-User mailing list
SciPy...@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user

Piter_

unread,
Jun 10, 2011, 8:53:02 AM6/10/11
to SciPy Users List
Hi.
In matlab I was doing it using global variables, but is has to be
better way with nested functions.
The idea is to rewrite your fitted function in the way that only not
fixed parameters are fed to optimization routine,
but fixed variables are still available to it.
Hope it helps a bit.
Best.
Petro.

Spark Liang

unread,
Jun 10, 2011, 1:13:58 PM6/10/11
to SciPy Users List
thanks, Petro.
I remember that matlab has such options in optimize toolsbox

Spark Liang

unread,
Jun 10, 2011, 1:16:36 PM6/10/11
to SciPy Users List
thanks, Josef.

I have done it by using mpfit, though it's not very easy.
Reply all
Reply to author
Forward
0 new messages