[SciPy-User] fmin / I'm sure this is a dumb syntax error on my part

Skipper Seabold jsseabold at gmail.com
Fri Oct 14 10:56:35 EDT 2011


On Thu, Oct 13, 2011 at 3:55 PM, tazzben <tazzben at me.com> wrote:
> So, I'm new to the optimization tools in scipy, so I'm trying to solve a
> problem I already know the answer to in an attempt to learn the system.
> What I'm trying to solve is:
> min of 100(y-x^2)^2+(1-x)^2
> solving for both x and y (the solution is 1,1).
> Based on the example, I tried this:
> from scipy.optimize import fmin
> def sFunction(x):
> return 100.0(x[1]-x[0]**2.0)**2.0 + (1.0-x[0])**2.0
> iv = [2.0, 5.0]
> fmin(sFunction, iv)
> Also in an earlier version I had x and y, but it wasn't working so I thought
> it might be better as an array.  So when I do this I get an error that says
> that a float is not callable.  What I think is happening is that it is
> substituting the initial guess in (thus it returns a float) but it isn't
> iterating for some reason.

You need a * Between 100.0 and (. It's treating the float like a
function and trying to call it.

Skipper

> I'm sure it's really stupid, but could someone explain what's suppose to be
> going on?
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>



More information about the SciPy-User mailing list