[SciPy-user] optimize.leastsq ier flag

Stephen Yang scyang@nist....
Tue Jul 31 10:30:07 CDT 2007

Hello everyone,

I'm getting an ier flag of '4' when I run this code to fit some data to 
a gaussian:

p0 = [1, 1, 1]

gauss = lambda p, x: p[0]*numpy.exp(-((x-p[1])**2/(2*p[2]**2)))
res = lambda p, x, y: gauss(p, x) - y
optimized, success = optimize.minpack.leastsq(res, p0, args = (omega, 
print 'success flag:', success

In the minpack documentation, there is supposedly a 'mesg' return value, 
which states:

    mesg -- a string message giving information about the cause of failure.

So.. first, does anyone know what a flag of '4' means? Secondly, how 
would you go about getting this flag? I tried

optimized, mesg, success = optimize.minpack.leastsq(res, p0, args = 
(omega, counts))

with no luck..
ValueError: need more than 2 values to unpack

Any help would be greatly appreciated.

More information about the SciPy-user mailing list