integration¶
This module contains functions for the numeric as well as the analytic (partial) integration.
-
class
zfit.core.integration.
AnalyticIntegral
(*args, **kwargs)[source]¶ Bases:
object
Hold analytic integrals and manage their dimensions, limits etc.
-
get_max_axes
(limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool], axes: Union[int, Iterable[int]] = None) → Tuple[int][source]¶ Return the maximal available axes to integrate over analytically for given limits
Parameters: Returns: Return type: Tuple[int]
-
get_max_integral
(limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool], axes: Union[int, Iterable[int]] = None) → Union[None, zfit.core.integration.Integral][source]¶ Return the integral over the limits with axes (or a subset of them).
Parameters: - limits (
ZfitSpace
) – - axes (Tuple[int]) –
Returns: Return a callable that integrated over the given limits.
Return type: - limits (
-
integrate
(x: Union[float, tensorflow.python.framework.ops.Tensor, None], limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool], axes: Union[int, Iterable[int]] = None, norm_range: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, model: zfit.core.interfaces.ZfitModel = None, params: dict = None) → Union[float, tensorflow.python.framework.ops.Tensor][source]¶ Integrate analytically over the axes if available.
Parameters: - x (numeric) – If a partial integration is made, x are the value to be evaluated for the partial integrated function. If a full integration is performed, this should be None.
- limits (
ZfitSpace
) – The limits to integrate - axes (Tuple[int]) – The dimensions to integrate over
- norm_range (bool) – |norm_range_arg_descr|
- params (dict) – The parameters of the function
Returns: Return type: Union[tf.Tensor, float]
Raises: AnalyticIntegralNotImplementedError
– If the requested integral is not available.
-
register
(func: Callable, limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool], priority: int = 50, *, supports_norm_range: bool = False, supports_multiple_limits: bool = False) → None[source]¶ Register an analytic integral.
Parameters: - func (callable) – The integral function. Takes 1 argument.
- axes (tuple) – |dims_arg_descr|
- limits (possible) – |limits_arg_descr| Limits can be None if func works for any
- limits –
- priority (int) – If two or more integrals can integrate over certain limits, the one with the higher priority is taken (usually around 0-100).
- supports_norm_range (bool) – If True, norm_range will (if needed) be given to func as an argument.
- supports_multiple_limits (bool) – If True, multiple limits may be given as an argument to func.
-
-
class
zfit.core.integration.
Integral
(func: Callable, limits: zfit.core.interfaces.ZfitSpace, priority: Union[int, float])[source]¶ Bases:
object
A lightweight holder for the integral function.
-
class
zfit.core.integration.
PartialIntegralSampleData
(sample: List[tensorflow.python.framework.ops.Tensor], space: zfit.core.interfaces.ZfitSpace)[source]¶ Bases:
zfit.core.dimension.BaseDimensional
,zfit.core.interfaces.ZfitData
Takes a list of tensors and “fakes” a dataset. Useful for tensors with non-matching shapes.
Parameters: - sample (List[tf.Tensor]) –
- () (space) –
-
axes
¶ Return the axes, integer based identifier(indices) for the coordinate system.
-
n_obs
¶ Return the number of observables, the dimensionality. Corresponds to the last dimension.
-
obs
¶ Return the observables, string identifier for the coordinate system.
-
space
¶
-
weights
¶
-
zfit.core.integration.
auto_integrate
(*, norm_range: bool = False, multiple_limits: bool = False) → Callable[source]¶
-
zfit.core.integration.
mc_integrate
(func: Callable, limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool], axes: Union[int, Iterable[int], None] = None, x: Union[float, tensorflow.python.framework.ops.Tensor, None] = None, n_axes: Optional[int] = None, draws_per_dim: int = 20000, method: str = None, dtype: Type[CT_co] = tf.float64, mc_sampler: Callable = <function sample_halton_sequence>, importance_sampling: Optional[Callable] = None) → tensorflow.python.framework.ops.Tensor[source]¶ Monte Carlo integration of func over limits.
Parameters: - func (callable) – The function to be integrated over
- limits (
ZfitSpace
) – The limits of the integral - axes (tuple(int)) – The row to integrate over. None means integration over all value
- x (numeric) – If a partial integration is performed, this are the value where x will be evaluated.
- n_axes (int) – the number of total dimensions (old?)
- draws_per_dim (int) – How many random points to draw per dimensions
- method (str) – Which integration method to use
- dtype (dtype) – |dtype_arg_descr|
- mc_sampler (callable) – A function that takes one argument (n_draws or similar) and returns random value between 0 and 1.
- () (importance_sampling) –
Returns: the integral
Return type: numerical
-
zfit.core.integration.
normalization_chunked
(func, n_axes, batch_size, num_batches, dtype, space, x=None, shape_after=())[source]¶