[SciPy-User] leastsq - output integer flag

David Baddeley david_baddeley at yahoo.com.au
Mon Jun 27 17:21:34 EDT 2011


>From the minpack source:

c     info is an integer output variable. if the user has
c         terminated execution, info is set to the (negative) c         value of 
iflag. see description of fcn. otherwise, c         info is set as follows. c c         
info = 0  improper input parameters. c c         info = 1  both actual and 
predicted relative reductions c                   in the sum of squares are at 
most ftol. c c         info = 2  relative error between two consecutive iterates 
c                   is at most xtol. c c         info = 3  conditions for info = 
1 and info = 2 both hold. c c         info = 4  the cosine of the angle between 
fvec and any c                   column of the jacobian is at most gtol in c                   
absolute value. c c         info = 5  number of calls to fcn with iflag = 1 has 
c                   reached maxfev. c c         info = 6  ftol is too small. no 
further reduction in c                   the sum of squares is possible. c c         
info = 7  xtol is too small. no further improvement in c                   the 
approximate solution x is possible. c c         info = 8  gtol is too small. 
fvec is orthogonal to the c                   columns of the jacobian to machine 
precision.

using full_output=1, you can get covariance matrix (cov_x) in the documentation 
and use this to estimate errors in each of the parameters by doing something 
like:
res, cov_x, infodict, mesg, resCode = scipy.optimize.leastsq(..., full_output=1)
fitErrors = 
scipy.sqrt(scipy.diag(cov_x)*(infodict['fvec']*infodict['fvec']).sum()/(Nobservations
 - Nparameters))
cheers,
David



----- Original Message ----
From: Johannes Radinger <johradinger at googlemail.com>
To: scipy-user at scipy.org
Sent: Mon, 27 June, 2011 10:34:07 PM
Subject: [SciPy-User] leastsq - output integer flag

Hello,

i am using leastsq to optimize a function. Beside the fitted output
variables also an integer flag
(number 1-4) is returned.
What do the numbers acutally mean?

Is there any simple possiblity to get a measure for the accuracy of
the fit/optimization, like the residuals etc.?

cheers
/johannes
_______________________________________________
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