PoissonConstraint#
- class zfit.constraint.PoissonConstraint(params, observation)[source]#
Bases:
TFProbabilityConstraint,SerializableMixinPoisson constraints on a list of parameters to some observed values.
Constraints parameters that can be counts (i.e. from a histogram) or, more generally, are Poisson distributed. This is often used in the case of histogram templates which are obtained from simulation and have a poisson uncertainty due to limited statistics.
\[\text{constraint} = \text{Poisson}(\text{observation}; \text{params})\]- Parameters:
params (
TypeVar(ParamTypeInput, zfit.interface.ZfitParameter,Union[int,float,complex,tf.Tensor, zfit.interface.ZfitParameter])) – The parameters to constraint; corresponds to the mu in the Poisson distribution.observation (
Union[int,float,complex,tf.Tensor,ZfitParameter]) – observed values of the parameter; corresponds to lambda in the Poisson distribution.
- Raises:
ShapeIncompatibleError – If params and observation have incompatible shapes.
- __str__()#
Return a user-friendly string representation of the probability constraint.
- Return type:
- add_cache_deps(cache_deps, allow_non_cachable=True)#
Add dependencies that render the cache invalid if they change.
- property dtype: DType#
The dtype of the object.
- classmethod from_asdf(asdf_obj, *, reuse_params=None)#
Load an object from an asdf file.
- Parameters:
asdf_obj – Object
reuse_params – If parameters, the parameters will be reused if they are given. If a parameter is given, it will be used as the parameter with the same name. If a parameter is not given, a new parameter will be created.
- classmethod from_dict(dict_, *, reuse_params=None)#
Creates an object from a dictionary structure as generated by
to_dict.- Parameters:
dict – Dictionary structure.
reuse_params – If parameters, the parameters will be reused if they are given. If a parameter is given, it will be used as the parameter with the same name. If a parameter is not given, a new parameter will be created.
- Returns:
The deserialized object.
- classmethod from_json(cls, json, *, reuse_params=None)#
Load an object from a json string.
- Parameters:
json (
str) – Serialized object in a JSON string.reuse_params – If parameters, the parameters will be reused if they are given. If a parameter is given, it will be used as the parameter with the same name. If a parameter is not given, a new parameter will be created.
- Return type:
- Returns:
The deserialized object.
- get_params(floating=True, is_yield=None, extract_independent=True, *, autograd=None)#
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=Nonewill return parameters that are floating as well as parameters that are fixed.
- None: do not filter on this. E.g.
True: only return parameters that fulfil this criterion
- False: only return parameters that do not fulfil this criterion. E.g.
floating=Falsewill return only parameters that are not floating.
- False: only return parameters that do not fulfil this criterion. E.g.
- Parameters:
floating (
bool|None) – if a parameter is floating, e.g. iffloating()returnsTrueis_yield (
bool|None) – 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 (
bool|None) – If the parameter is an independent parameter, i.e. if it is aZfitIndependentParameter.
- Return type:
OrderedSet[ZfitParameter]
- classmethod get_repr()#
Abstract representation of the object for serialization.
This objects knows how to serialize and deserialize the object and is used by the
to_json,from_json,to_dictandfrom_dictmethods.- Returns:
The representation of the object.
- Return type:
pydantic.BaseModel
- register_cacher(cacher)#
Register a
cacherthat caches values produces by this instance; a dependent.- Parameters:
cacher
- reset_cache_self()#
Clear the cache of self and all dependent cachers.
- sample(n)#
Sample
npoints from the probability density function for the observed value of the parameters.
- to_asdf()#
Convert the object to an asdf file.
- to_dict()#
Convert the object to a nested dictionary structure.
- Return type:
- Returns:
The dictionary structure.