pulse2percept.utils.optimize
Functions
|
Binary search (bisection method) to find x value that gives y_target |
- pulse2percept.utils.optimize.bisect(y_target, func, args=None, kwargs=None, x_lo=0, x_hi=1, x_tol=1e-06, y_tol=0.001, max_iter=100)[source]
Binary search (bisection method) to find x value that gives y_target
For a function
y = func(x, *args, **kwargs), returnsx_optfor whichfunc(x_opt, *args, **kwargs)is approximately equal toy_target.Added in version 0.7.
- Parameters:
y_target (float) – Target y value
func (optional) – The function to call along with its positional and keyword arguments
args (optional) – The function to call along with its positional and keyword arguments
kwargs (optional) – The function to call along with its positional and keyword arguments
x_lo (float, optional) – Lower and upper bounds on
xx_hi (float, optional) – Lower and upper bounds on
xx_tol (float, optional) – Search will stop if the range of candidate
xvalues is smaller thanx_toly_tol (float, optional) – Search will stop if
yis withiny_tolofy_targetmax_iter (int, optional) – Maximum number of iterations to run
- Returns:
x_opt – The x value such that func(x_opt) $approx$ y_target
- Return type:
Notes
Assumes
funcis a monotonously increasing function ofx.Does not require
x_loandx_hito have opposite signs as in the conventional bisection method.