[SciPy-user] (no subject)

Anne Archibald peridot.faceted@gmail....
Wed Jun 18 10:47:05 CDT 2008


2008/6/18 Jose Lopez <lopmart@gmail.com>:
> Hi, my code is the next and i  have a error, but i not know what i do:
>
> from pylab import *
> from scipy import *
>
> def func(b,Hder):
>     return (Hder[0]-(b[0]-b[1]))**2 + (Hder[1]-(b[1]-b[2]))**2+
> (Hder[2]-(b[2]-b[3]))**2+ (Hder[3]-(b[3]-100.0))**2
>
>
> b0=[0.0,0.0,0.0,0.0]
> H0=[0.0,-50.0,20.0,-20.0]
>
> xopt =optimize.fmin_l_bfgs_b(func,b0,args=(H0))

args should be a list or tuple of extra arguments to pass to func. In
python syntax, (H0) is the same thing has H0, which is a list with
four elements, so fmin_l_bfgs_b treats it as four additional
arguments, rather than one argument that is a list. You should instead
provide args= with a list or tuple of only one element. The most
readable way to do this is to write args=[H0], but if you want to use
a tuple, you should write (H0,) (that is, with a trailing comma, to
indicate that it's a tuple).

Anne


More information about the SciPy-user mailing list