# GaussianConstraint¶

class zfit.constraint.GaussianConstraint(params, observation, uncertainty)[source]

Bases: zfit.core.constraint.TFProbabilityConstraint

Gaussian constraints on a list of parameters to some observed values with uncertainties.

A Gaussian constraint is defined as the likelihood of params given the observations and uncertainty from a different measurement.

$\text{constraint} = \text{Gauss}(\text{observation}; \text{params}, \text{uncertainty})$
Parameters
• params (~ParamTypeInput) – The parameters to constraint; corresponds to x in the Gaussian distribution.

• observation (Union[int, float, complex, Tensor, ForwardRef]) – observed values of the parameter; corresponds to mu in the Gaussian distribution.

• uncertainty (Union[int, float, complex, Tensor, ForwardRef]) – Uncertainties or covariance/error matrix of the observed values. Can either be a single value, a list of values, an array or a tensor. Corresponds to the sigma of the Gaussian distribution.

Raises

ShapeIncompatibleError – If params, mu and sigma have incompatible shapes.

property covariance

Return the covariance matrix of the observed values of the parameters constrained.

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.

property dtype: tensorflow.python.framework.dtypes.DType

The dtype of the object.

Return type

DType

get_cache_deps(only_floating=True)

Return a set of all independent Parameter that this object depends on.

Parameters

only_floating (bool) – If True, only return floating Parameter

Return type

OrderedSet

get_dependencies(only_floating=True)

DEPRECATED FUNCTION

Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use get_params instead if you want to retrieve the independent parameters or get_cache_deps in case you need the numerical cache dependents (advanced).

get_params(floating=True, is_yield=None, extract_independent=True, only_floating=<class 'zfit.util.checks.NotSpecified'>)

Recursively collect parameters that this object depends on according to the filter criteria.

Which parameters should be included can be steered using the arguments as a filter.
• None: do not filter on this. E.g. floating=None will return parameters that are floating as well as

parameters that are fixed.

• True: only return parameters that fulfil this criterion

• False: only return parameters that do not fulfil this criterion. E.g. floating=False will return

only parameters that are not floating.

Parameters
• floating (Optional[bool]) – if a parameter is floating, e.g. if floating() returns True

• is_yield (Optional[bool]) – if a parameter is a yield of the _current_ model. This won’t be applied recursively, but may include yields if they do also represent a parameter parametrizing the shape. So if the yield of the current model depends on other yields (or also non-yields), this will be included. If, however, just submodels depend on a yield (as their yield) and it is not correlated to the output of our model, they won’t be included.

• extract_independent (Optional[bool]) – If the parameter is an independent parameter, i.e. if it is a ZfitIndependentParameter.

Return type

Set[ZfitParameter]

property name: str

The name of the object.

Return type

str

property observation

Return the observed values of the parameters constrained.

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.

sample(n)

Sample n points from the probability density function for the observed value of the parameters.

Parameters

n – The number of samples to be generated.

Returns: