def onebyone(transform, loglikelihood, parameter_names, prior, start = <NUM_LIT:0.5>, ftol=<NUM_LIT:0.1>, disp=<NUM_LIT:0>, nsteps=<NUM_LIT>,<EOL>parallel=False, find_uncertainties=False, **args):
def minfunc(cube):<EOL><INDENT>cube = numpy.array(cube)<EOL>if (cube <= <NUM_LIT>).any() or (cube >= <NUM_LIT:1>-<NUM_LIT>).any():<EOL><INDENT>return <NUM_LIT><EOL><DEDENT>params = transform(cube)<EOL>l = loglikelihood(params)<EOL>p = prior(params)<EOL>if numpy.isinf(p) and p < <NUM_LIT:0>:<EOL><INDENT>print('<STR_LIT>')<EOL>return -<NUM_LIT><EOL><DEDENT>if numpy.isnan(l):<EOL><INDENT>return -<NUM_LIT><EOL><DEDENT>return -l - p<EOL><DEDENT>if parallel:<EOL><INDENT>func = opt_grid_parallel<EOL><DEDENT>else:<EOL><INDENT>func = opt_grid<EOL><DEDENT>n_params = len(parameter_names)<EOL>start = start + numpy.zeros(n_params)<EOL>ret = func(start, minfunc, [(<NUM_LIT>, <NUM_LIT:1>-<NUM_LIT>)] * n_params, ftol=ftol, disp=disp, compute_errors=find_uncertainties)<EOL>if find_uncertainties:<EOL><INDENT>c0 = ret[<NUM_LIT:0>]<EOL>p0 = transform(c0)<EOL>stdev = numpy.zeros(n_params)<EOL>lower = numpy.zeros(n_params)<EOL>upper = numpy.zeros(n_params)<EOL>for i, (lo, hi) in enumerate(ret[<NUM_LIT:1>]):<EOL><INDENT>c1 = numpy.copy(c0)<EOL>c1[i] = lo<EOL>c2 = numpy.copy(c0)<EOL>c2[i] = hi<EOL>p1 = transform(c1)<EOL>p2 = transform(c2)<EOL>stdev[i] = numpy.abs(p2[i] - p1[i]) / <NUM_LIT:2><EOL>lower[i] = min(p2[i], p1[i])<EOL>upper[i] = max(p2[i], p1[i])<EOL><DEDENT>return dict(start=ret[<NUM_LIT:0>], maximum=p0,<EOL>stdev=stdev, upper=upper, lower=lower,<EOL>method='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>return dict(start=ret, maximum=transform(ret), method='<STR_LIT>')<EOL><DEDENT>
**Convex optimization based on Brent's method**

A strict assumption of one optimum between the parameter limits is used.
The bounds are narrowed until it is found, i.e. the likelihood function is flat
within the bounds.
* If optimum outside bracket, expands bracket until contained.
* Thus guaranteed to return local optimum.
* Supports parallelization (multiple parameters are treated independently)
* Supports finding ML uncertainties (Delta-Chi^2=1)

Very useful for 1-3d problems.
Otherwise useful, reproducible/deterministic algorithm for finding the minimum in 
well-behaved likelihoods, where the parameters are weakly independent,
or to find a good starting point. 
Optimizes each parameter in order, assuming they are largely independent.

For 1-dimensional algorithm used, see :func:`jbopt.opt_grid`

:param ftol: difference in values at which the function can be considered flat
:param compute_errors: compute standard deviation of gaussian around optimum