开发者

Scipy Leastsq Optional Output Variable (Mesg)

开发者 https://www.devze.com 2023-03-26 04:49 出处:网络
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 o

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

精彩评论

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