constraint¶
-
class
zfit.core.constraint.
BaseConstraint
(params: Dict[str, zfit.core.interfaces.ZfitParameter] = None, name: str = 'BaseConstraint', dtype=tf.float64, **kwargs)[source]¶ Bases:
zfit.core.interfaces.ZfitConstraint
,zfit.core.baseobject.BaseNumeric
Base class for constraints.
Parameters: -
add_cache_dependents
(cache_dependents: Union[zfit.core.interfaces.ZfitCachable, Iterable[zfit.core.interfaces.ZfitCachable]], allow_non_cachable: bool = True)¶ Add dependents that render the cache invalid if they change.
Parameters: - cache_dependents (ZfitCachable) –
- 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.
-
copy
(deep: bool = False, name: str = None, **overwrite_params) → zfit.core.interfaces.ZfitObject¶
-
dtype
¶ The dtype of the object
-
get_dependents
(only_floating: bool = True) -> OrderedSet(['z', 'f', 'i', 't', '.', 'P', 'a', 'r', 'm', 'e'])¶ Return a set of all independent
Parameter
that this object depends on.Parameters: only_floating (bool) – If True, only return floating Parameter
-
get_params
(only_floating: bool = False, names: Union[str, List[str], None] = None) → List[ZfitParameter]¶ Return the parameters. If it is empty, automatically return all floating variables.
Parameters: - () (names) – If True, return only the floating parameters.
- () – The names of the parameters to return.
Returns: Return type: list(ZfitParameters)
-
graph_caching_methods
= []¶
-
name
¶ The name of the object.
-
old_graph_caching_methods
= []¶
-
params
¶
-
register_cacher
(cacher: Union[zfit.core.interfaces.ZfitCachable, Iterable[zfit.core.interfaces.ZfitCachable]])¶ Register a cacher that caches values produces by this instance; a dependent.
Parameters: () (cacher) –
-
reset_cache
(reseter: zfit.util.cache.ZfitCachable)¶
-
reset_cache_self
()¶ Clear the cache of self and all dependent cachers.
-
-
class
zfit.core.constraint.
DistributionConstraint
(params: Dict[str, zfit.core.interfaces.ZfitParameter], distribution: tensorflow_probability.python.distributions.distribution.Distribution, dist_params, dist_kwargs=None, name: str = 'DistributionConstraint', dtype=tf.float64, **kwargs)[source]¶ Bases:
zfit.core.constraint.BaseConstraint
Base class for constraints using a probability density function.
Parameters: distribution (tensorflow_probability.distributions.Distribution) – The probability density function used to constraint the parameters -
add_cache_dependents
(cache_dependents: Union[zfit.core.interfaces.ZfitCachable, Iterable[zfit.core.interfaces.ZfitCachable]], allow_non_cachable: bool = True)¶ Add dependents that render the cache invalid if they change.
Parameters: - cache_dependents (ZfitCachable) –
- 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.
-
copy
(deep: bool = False, name: str = None, **overwrite_params) → zfit.core.interfaces.ZfitObject¶
-
distribution
¶
-
dtype
¶ The dtype of the object
-
get_dependents
(only_floating: bool = True) -> OrderedSet(['z', 'f', 'i', 't', '.', 'P', 'a', 'r', 'm', 'e'])¶ Return a set of all independent
Parameter
that this object depends on.Parameters: only_floating (bool) – If True, only return floating Parameter
-
get_params
(only_floating: bool = False, names: Union[str, List[str], None] = None) → List[ZfitParameter]¶ Return the parameters. If it is empty, automatically return all floating variables.
Parameters: - () (names) – If True, return only the floating parameters.
- () – The names of the parameters to return.
Returns: Return type: list(ZfitParameters)
-
graph_caching_methods
= []¶
-
name
¶ The name of the object.
-
old_graph_caching_methods
= []¶
-
params
¶
-
register_cacher
(cacher: Union[zfit.core.interfaces.ZfitCachable, Iterable[zfit.core.interfaces.ZfitCachable]])¶ Register a cacher that caches values produces by this instance; a dependent.
Parameters: () (cacher) –
-
reset_cache
(reseter: zfit.util.cache.ZfitCachable)¶
-
reset_cache_self
()¶ Clear the cache of self and all dependent cachers.
-
sample
(n)¶ Sample n points from the probability density function for the constrained parameters.
Parameters: n (int, tf.Tensor) – The number of samples to be generated. Returns: n_samples) Return type: Dict(Parameter
-
value
()¶
-
-
class
zfit.core.constraint.
GaussianConstraint
(params: Union[zfit.core.interfaces.ZfitParameter, int, float, complex, tensorflow.python.framework.ops.Tensor], mu: Union[int, float, complex, tensorflow.python.framework.ops.Tensor], sigma: Union[int, float, complex, tensorflow.python.framework.ops.Tensor])[source]¶ Bases:
zfit.core.constraint.DistributionConstraint
Gaussian constraints on a list of parameters.
Parameters: - params (list(zfit.Parameter)) – The parameters to constraint
- mu (numerical, list(numerical)) – The central value of the constraint
- sigma (numerical, list(numerical) or array/tensor) – The standard deviations or covariance matrix of the constraint. Can either be a single value, a list of values, an array or a tensor
Raises: ShapeIncompatibleError
– if params, mu and sigma don’t have incompatible shapes-
add_cache_dependents
(cache_dependents: Union[zfit.core.interfaces.ZfitCachable, Iterable[zfit.core.interfaces.ZfitCachable]], allow_non_cachable: bool = True)¶ Add dependents that render the cache invalid if they change.
Parameters: - cache_dependents (ZfitCachable) –
- 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.
-
copy
(deep: bool = False, name: str = None, **overwrite_params) → zfit.core.interfaces.ZfitObject¶
-
distribution
¶
-
dtype
¶ The dtype of the object
-
get_dependents
(only_floating: bool = True) -> OrderedSet(['z', 'f', 'i', 't', '.', 'P', 'a', 'r', 'm', 'e'])¶ Return a set of all independent
Parameter
that this object depends on.Parameters: only_floating (bool) – If True, only return floating Parameter
-
get_params
(only_floating: bool = False, names: Union[str, List[str], None] = None) → List[ZfitParameter]¶ Return the parameters. If it is empty, automatically return all floating variables.
Parameters: - () (names) – If True, return only the floating parameters.
- () – The names of the parameters to return.
Returns: Return type: list(ZfitParameters)
-
graph_caching_methods
= []¶
-
name
¶ The name of the object.
-
old_graph_caching_methods
= []¶
-
params
¶
-
register_cacher
(cacher: Union[zfit.core.interfaces.ZfitCachable, Iterable[zfit.core.interfaces.ZfitCachable]])¶ Register a cacher that caches values produces by this instance; a dependent.
Parameters: () (cacher) –
-
reset_cache
(reseter: zfit.util.cache.ZfitCachable)¶
-
reset_cache_self
()¶ Clear the cache of self and all dependent cachers.
-
sample
(n)¶ Sample n points from the probability density function for the constrained parameters.
Parameters: n (int, tf.Tensor) – The number of samples to be generated. Returns: n_samples) Return type: Dict(Parameter
-
value
()¶
-
class
zfit.core.constraint.
SimpleConstraint
(func: Callable, params: Optional[Dict[str, zfit.core.interfaces.ZfitParameter]], sampler: Callable = None)[source]¶ Bases:
zfit.core.constraint.BaseConstraint
Constraint from a (function returning a) Tensor.
The parameters are named “param_{i}” with i starting from 0 and corresponding to the index of params.
Parameters: - func – Callable that constructs the constraint and returns a tensor.
- dependents – The dependents (independent zfit.Parameter) of the loss. If not given, the dependents are figured out automatically.
-
add_cache_dependents
(cache_dependents: Union[zfit.core.interfaces.ZfitCachable, Iterable[zfit.core.interfaces.ZfitCachable]], allow_non_cachable: bool = True)¶ Add dependents that render the cache invalid if they change.
Parameters: - cache_dependents (ZfitCachable) –
- 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.
-
copy
(deep: bool = False, name: str = None, **overwrite_params) → zfit.core.interfaces.ZfitObject¶
-
dtype
¶ The dtype of the object
-
get_dependents
(only_floating: bool = True) -> OrderedSet(['z', 'f', 'i', 't', '.', 'P', 'a', 'r', 'm', 'e'])¶ Return a set of all independent
Parameter
that this object depends on.Parameters: only_floating (bool) – If True, only return floating Parameter
-
get_params
(only_floating: bool = False, names: Union[str, List[str], None] = None) → List[ZfitParameter]¶ Return the parameters. If it is empty, automatically return all floating variables.
Parameters: - () (names) – If True, return only the floating parameters.
- () – The names of the parameters to return.
Returns: Return type: list(ZfitParameters)
-
graph_caching_methods
= []¶
-
name
¶ The name of the object.
-
old_graph_caching_methods
= []¶
-
params
¶
-
register_cacher
(cacher: Union[zfit.core.interfaces.ZfitCachable, Iterable[zfit.core.interfaces.ZfitCachable]])¶ Register a cacher that caches values produces by this instance; a dependent.
Parameters: () (cacher) –
-
reset_cache
(reseter: zfit.util.cache.ZfitCachable)¶
-
reset_cache_self
()¶ Clear the cache of self and all dependent cachers.
-
sample
(n)¶ Sample n points from the probability density function for the constrained parameters.
Parameters: n (int, tf.Tensor) – The number of samples to be generated. Returns: n_samples) Return type: Dict(Parameter
-
value
()¶