2

SciPy's documentation on LeastSq is here. It states that ier is

An integer flag. If it is equal to 1, 2, 3 or 4, the solution was found. Otherwise, the solution was not found. In either case, the optional output variable ‘mesg’ gives more information.

But how do I retrieve the optional variable mesg?

x,ier=leastsq(residuals, plsq, args=(x_vals, y_vals)) gives me only two returns while

x,mesg,ier=leastsq(residuals, plsq, args=(x_vals, y_vals)) gives the error message ValueError: need more than 2 values to unpack on that line.

Richard
  • 56,349
  • 34
  • 180
  • 251

1 Answers1

3

Use the full_output parameter:

import scipy.optimize as optimize
p,cov,infodict,mesg,ier = optimize.leastsq(
    residuals,p_guess,args=(x,y),full_output=True)
unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677
  • Seems that this is not explained in the documentation. I would expect few words like "if `full_output` is set to `True`" in the description of the returns `cov`,`infodict` and `mesg`. – altroware Jan 12 '15 at 11:08