scalar_maximization
- quantecon.optimize.scalar_maximization.brent_max(func, a, b, args=(), xtol=1e-05, maxiter=500)[source]
Uses a jitted version of the maximization routine from SciPy’s fminbound. The algorithm is identical except that it’s been switched to maximization rather than minimization, and the tests for convergence have been stripped out to allow for jit compilation.
Note that the input function func must be jitted or the call will fail.
- Parameters:
- funcjitted function
- ascalar
Lower bound for search
- bscalar
Upper bound for search
- argstuple, optional
Extra arguments passed to the objective function.
- maxiterint, optional
Maximum number of iterations to perform.
- xtolfloat, optional
Absolute error in solution xopt acceptable for convergence.
- Returns:
- xffloat
The maximizer
- fvalfloat
The maximum value attained
- infotuple
A tuple of the form (status_flag, num_iter). Here status_flag indicates whether or not the maximum number of function calls was attained. A value of 0 implies that the maximum was not hit. The value num_iter is the number of function calls.
Examples
>>> @njit ... def f(x): ... return -(x + 2.0)**2 + 1.0 ... >>> xf, fval, info = brent_max(f, -2, 2)