fitresult

class zfit.minimizers.fitresult.FitResult(params: Dict[zfit.core.interfaces.ZfitParameter, float], edm: float, fmin: float, status: int, converged: bool, info: dict, loss: zfit.core.interfaces.ZfitLoss, minimizer: zfit.minimizers.interface.ZfitMinimizer)[source]

Bases: 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}}

Parameters

params (OrderedDict[Parameter, float]) – Result of the fit where each

:param Parameter key has the value: from the minimum found by the minimizer. :param edm: The estimated distance to minimum, estimated by the minimizer (if available) :type edm: Union[int, float] :param fmin: The minimum of the function found by the minimizer :type fmin: Union[numpy.float64, float] :param status: A status code (if available) :type status: int :param converged: Whether the fit has successfully converged or not. :type converged: bool :param info: Additional information (if available) like number of function calls and the

original minimizer return message.

Parameters
  • loss (Union[ZfitLoss]) – The loss function that was minimized. Contains also the pdf, data etc.

  • 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.

property converged
covariance(params: Optional[Iterable[zfit.core.interfaces.ZfitParameter]] = None, as_dict: bool = False)[source]

Calculate the covariance matrix for params.

Parameters
  • params (list(Parameter)) – The parameters to calculate the covariance matrix. If params is None, use all floating parameters.

  • as_dict (bool) – Default False. If True then returns a dictionnary.

Returns

2D numpy.array of shape (N, N); dict`(param1, param2) -> covariance if `as_dict == True.

property edm

The estimated distance to the minimum.

Returns

numeric

error(params: Optional[Iterable[zfit.core.interfaces.ZfitParameter]] = None, method: Union[str, Callable] = 'minuit_minos', error_name: str = None, sigma: float = 1.0) → collections.OrderedDict[source]

Calculate and set for params the asymmetric error using the set error method.

Parameters
  • params (list(Parameter or str)) – The parameters or their names to calculate the errors. If params is None, use all floating parameters.

  • method (str or Callable) – 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.

  • error_name (str) – The name for the error in the dictionary.

Returns

A OrderedDict containing as keys the parameter names and as value a dict which

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’

Return type

OrderedDict

property fmin

Function value at the minimum.

Returns

numeric

hesse(params: Optional[Iterable[zfit.core.interfaces.ZfitParameter]] = None, method: Union[str, Callable] = 'minuit_hesse', error_name: Optional[str] = None, sigma=1.0) → collections.OrderedDict[source]

Calculate for params the symmetric error using the Hessian matrix.

Parameters
  • params (list(Parameter)) – The parameters to calculate the Hessian symmetric error. If None, use all parameters.

  • method (str) – the method to calculate the hessian. Can be {‘minuit’} or a callable.

  • error_name (str) – The name for the error in the dictionary.

Returns

Result of the hessian (symmetric) error as dict with each parameter holding

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.

Return type

OrderedDict

property info
property loss
property minimizer
property params
property status
zfit.minimizers.fitresult.dict_to_matrix(params, matrix_dict)[source]