开发者

Scipy Leastsq Optional Output Variable (Mesg)

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,开发者_StackOverflow社区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.


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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜