Minuit

class zfit.minimize.Minuit(strategy=None, minimize_strategy=1, tolerance=None, verbosity=5, name=None, ncall=None, use_minuit_grad=None, **minimizer_options)[source]

Bases: zfit.minimizers.baseminimizer.BaseMinimizer, zfit.util.cache.GraphCachable

Parameters
  • strategy (Optional[ZfitStrategy]) – A ZfitStrategy object that defines the behavior of

  • minimizer in certain situations. (the) –

  • minimize_strategy (int) – A number used by minuit to define the strategy, either 0, 1 or 2.

  • tolerance (Optional[float]) – Stopping criteria: the Estimated Distance to Minimum (EDM) has to be lower then tolerance

  • verbosity (int) – Regulates how much will be printed during minimization. Values between 0 and 10 are valid.

  • name (Optional[str]) – Name of the minimizer

  • ncall (Optional[int]) – Maximum number of minimization steps.

  • use_minuit_grad (Optional[bool]) – If True, iminuit uses it’s internal numerical gradient calculation instead of the (analytic/numerical) gradient provided by TensorFlow/zfit.

add_cache_deps(cache_deps, allow_non_cachable=True)

Add dependencies that render the cache invalid if they change.

Parameters
  • cache_deps (Union[ForwardRef, Iterable[ForwardRef]]) –

  • allow_non_cachable (bool) – If True, allow cache_dependents to be non-cachables. If False, any cache_dependents that is not a ZfitCachable will raise an error.

Raises

TypeError – if one of the cache_dependents is not a ZfitCachable _and_ allow_non_cachable if False.

minimize(loss, params=None)

Fully minimize the loss with respect to params.

Parameters
  • loss (ZfitLoss) – Loss to be minimized.

  • params (Optional[Iterable[ZfitParameter]]) – The parameters with respect to which to minimize the loss. If None, the parameters will be taken from the loss.

Return type

FitResult

Returns

The fit result.

register_cacher(cacher)

Register a cacher that caches values produces by this instance; a dependent.

Parameters

cacher (Union[ForwardRef, Iterable[ForwardRef]]) –

reset_cache_self()

Clear the cache of self and all dependent cachers.

step(loss, params=None)

Perform a single step in the minimization (if implemented).

Parameters

params (Union[Iterable[ZfitParameter], None, Iterable[str]]) –

Returns:

Raises

MinimizeStepNotImplementedError – if the step method is not implemented in the minimizer.