zfit.minimize.
FitResult
Bases: zfit.minimizers.interface.ZfitResult
zfit.minimizers.interface.ZfitResult
Create a FitResult from a minimization. Store parameter values, minimization infos and calculate errors.
Any errors calculated are saved under self.params dictionary with:
{parameter: {error_name1: {'low': value, 'high': value or similar}}
params (Dict[ZfitParameter, float]) – Result of the fit where each Parameter key has the value from the minimum found by the minimizer.
Dict
ZfitParameter
float
Parameter
edm (float) – The estimated distance to minimum, estimated by the minimizer (if available)
fmin (float) – The minimum of the function found by the minimizer
status (int) – A status code (if available)
int
converged (bool) – Whether the fit has successfully converged or not.
bool
info (dict) – Additional information (if available) like number of function calls and the original minimizer return message.
dict
loss (ZfitLoss) – The loss function that was minimized. Contains also the pdf, data etc.
ZfitLoss
minimizer (ZfitMinimizer) – Minimizer that was used to obtain this FitResult and will be used to calculate certain errors. If the minimizer is state-based (like “iminuit”), then this is a copy and the state of other FitResults or of the actual minimizer that performed the minimization won’t be altered.
ZfitMinimizer
from_minuit
Create a FitResult from a :py:class:~`iminuit.util.MigradResult` returned by iminuit.Minuit.migrad() and a iminuit :py:class:~`iminuit.Minuit` instance with the corresponding zfit objects.
iminuit.Minuit.migrad()
loss (ZfitLoss) – zfit Loss that was minimized.
params (Iterable[ZfitParameter]) – Iterable of the zfit parameters that were floating during the minimization.
Iterable
result (MigradResult) – Return value of the iminuit migrad command.
MigradResult
minimizer (Union[ZfitMinimizer, Minuit]) – Instance of the iminuit Minuit that was used to minimize the loss.
Union
Minuit
A FitResult as if zfit Minuit was used.
edm
The estimated distance to the minimum.
Numeric
fmin
Function value at the minimum.
hesse
Calculate for params the symmetric error using the Hessian/covariance matrix.
params (Optional[Iterable[ZfitParameter]]) – The parameters to calculate the Hessian symmetric error. If None, use all parameters.
Optional
method (Union[str, Callable, None]) – the method to calculate the covariance matrix. Can be {‘minuit_hesse’, ‘hesse_np’} or a callable.
str
Callable
None
error_name (Optional[str]) – The name for the error in the dictionary.
OrderedDict
the error dict {‘error’: sym_error}.
So given param_a (from zfit.Parameter(.)) error_a = result.hesse(params=param_a)[param_a][‘error’] error_a is the hessian error.
error
Deprecated since version unknown: Use errors() instead.
errors()
params (Optional[Iterable[ZfitParameter]]) – The parameters or their names to calculate the errors. If params is None, use all floating parameters.
method (Union[str, Callable, None]) – The method to use to calculate the errors. Valid choices are {‘minuit_minos’} or a Callable.
sigma (float) –
Errors are calculated with respect to sigma std deviations. The definition of 1 sigma depends on the loss function and is defined there.
For example, the negative log-likelihood (without the factor of 2) has a correspondents of \(\Delta\) NLL of 1 corresponds to 1 std deviation.
contains (next to probably more things) two keys ‘lower’ and ‘upper’, holding the calculated errors. Example: result[‘par1’][‘upper’] -> the asymmetric upper error of ‘par1’
errors
Calculate and set for params the asymmetric error using the set error method.
Tuple[OrderedDict, Optional[FitResult]]
Tuple
contains (next to probably more things) two keys ‘lower’ and ‘upper’, holding the calculated errors. Example: result[par1][‘upper’] -> the asymmetric upper error of ‘par1’
covariance
Calculate the covariance matrix for params.
params (Optional[Iterable[ZfitParameter]]) – The parameters to calculate the covariance matrix. If params is None, use all floating parameters.
method (Union[str, Callable, None]) – The method to use to calculate the covariance matrix. Valid choices are {‘minuit_hesse’, ‘hesse_np’} or a Callable.
as_dict (bool) – Default False. If True then returns a dictionnary.
2D numpy.array of shape (N, N); dict`(param1, param2) -> covariance if `as_dict == True.
correlation
Calculate the correlation matrix for params.
params (Optional[Iterable[ZfitParameter]]) – The parameters to calculate the correlation matrix. If params is None, use all floating parameters.
method (Union[str, Callable, None]) – The method to use to calculate the correlation matrix. Valid choices are {‘minuit_hesse’, ‘hesse_np’} or a Callable.
2D numpy.array of shape (N, N); dict`(param1, param2) -> correlation if `as_dict == True.