OptimizerMixin#
- class pyhf.optimize.mixins.OptimizerMixin(**kwargs)[source]#
Bases:
object
Mixin Class to build optimizers.
Attributes
- maxiter#
- verbose#
Methods
- _internal_minimize(func, x0, do_grad=False, bounds=None, fixed_vals=None, options={}, par_names=None)[source]#
- _internal_postprocess(fitresult, stitch_pars, return_uncertainties=False)[source]#
Post-process the fit result.
- Returns:
A modified version of the fit result.
- Return type:
fitresult (scipy.optimize.OptimizeResult)
- minimize(objective, data, pdf, init_pars, par_bounds, fixed_vals=None, return_fitted_val=False, return_result_obj=False, return_uncertainties=False, return_correlations=False, do_grad=None, do_stitch=False, **kwargs)[source]#
Find parameters that minimize the objective.
- Parameters:
objective (
func
) – objective functiondata (
list
) – observed datapdf (Model) – The statistical model adhering to the schema model.json
init_pars (
list
offloat
) – The starting values of the model parameters for minimization.par_bounds (
list
oflist
/tuple
) – The extrema of values the model parameters are allowed to reach in the fit. The shape should be(n, 2)
forn
model parameters.fixed_vals (
list
oflist
/tuple
) – The pairs of index and constant value for a constant model parameter during minimization. Set toNone
to allow all parameters to float.return_fitted_val (
bool
) – Return bestfit value of the objective. Default is off (False
).return_result_obj (
bool
) – Returnscipy.optimize.OptimizeResult
. Default is off (False
).return_uncertainties (
bool
) – Return uncertainties on the fitted parameters. Default is off (False
).return_correlations (
bool
) – Return correlations of the fitted parameters. Default is off (False
).do_grad (
bool
) – enable autodifferentiation mode. Default depends on backend (pyhf.tensorlib.default_do_grad
).do_stitch (
bool
) – enable splicing/stitching fixed parameter.kwargs – other options to pass through to underlying minimizer
- Returns:
parameters (
tensor
): fitted parametersminimum (
float
): ifreturn_fitted_val
flagged, return minimized objective valueresult (
scipy.optimize.OptimizeResult
): ifreturn_result_obj
flagged
- Return type:
Fitted parameters or tuple of results