[SciPy-User] ftol and xtol
GRBChaser
abeardmore@gmail....
Fri Jul 5 06:38:43 CDT 2013
On the subject of ftol and xtol, the help for fmin describes these
parameters as :
xtol : float
Relative error in xopt acceptable for convergence.
ftol : number
Relative error in func(xopt) acceptable for convergence.
The use of the word "Relative" here has always implied to me that the
convergence tests calculated by fmin refer to fractional changes in
parameters or function values. However, I had difficulties trying to
minimize a function in which the two parameters defer by many orders or
magnitude (e.g. 1 and 1e10) and I've come to the conclusion it is because
the large parameter never passes the convergence test.
The code in fmin which tests for convergence is :
if (max(numpy.ravel(abs(sim[1:]-sim[0]))) <= xtol \
and max(abs(fsim[0]-fsim[1:])) <= ftol):
break
This does not look like a test for the relative change in parameters or
function values to me, but rather a test for their absolute changes. A
relative change would surely be something like
if (max(numpy.ravel(abs((sim[1:]-sim[0])/sim[0]))) <= xtol \
and max(abs((fsim[0]-fsim[1:])/fsim[0])) <= ftol):
break
(though care should really be taken for possible divide by zero errors).
Either the docstring needs changing so "Relative" is replaced with
"Absolute" to make it clear, or the convergence test needs to be changed so
it truly is a relative error test.
--
View this message in context: http://scipy-user.10969.n7.nabble.com/ftol-and-xtol-tp18355p18518.html
Sent from the Scipy-User mailing list archive at Nabble.com.
More information about the SciPy-User
mailing list