sample¶
-
class
zfit.core.sample.
EventSpace
(obs: Union[str, Iterable[str], zfit.Space], limits: Union[Tuple[Tuple[Tuple[float, ...]]], Tuple[float, float], bool], factory=None, name: Optional[str] = 'Space')[source]¶ Bases:
zfit.core.limits.Space
EXPERIMENTAL SPACE CLASS!
-
ANY
= <Any>¶
-
ANY_LOWER
= <Any Lower Limit>¶
-
ANY_UPPER
= <Any Upper Limit>¶
-
AUTO_FILL
= <object object>¶
-
add
(other: Union[zfit.Space, Iterable[zfit.Space]])[source]¶ Add the limits of the spaces. Only works for the same obs.
In case the observables are different, the order of the first space is taken.
Parameters: other ( Space
) –Returns: Return type: Space
-
area
() → float¶ Return the total area of all the limits and axes. Useful, for example, for MC integration.
-
axes
¶ The axes (“obs with int”) the space is defined in.
Returns:
-
combine
(other: Union[zfit.Space, Iterable[zfit.Space]])[source]¶ Combine spaces with different obs (but consistent limits).
Parameters: other ( Space
) –Returns: Return type: Space
-
copy
(name: Optional[str] = None, **overwrite_kwargs) → zfit.Space¶ Create a new
Space
using the current attributes and overwriting with overwrite_overwrite_kwargs.Parameters: - name (str) – The new name. If not given, the new instance will be named the same as the current one.
- () (**overwrite_kwargs) –
Returns:
-
factory
¶
-
classmethod
from_axes
(axes: Union[int, Iterable[int]], limits: Union[Tuple[Tuple[Tuple[float, ...]]], Tuple[float, float], bool, None] = None, name: str = None) → zfit.Space¶ Create a space from axes instead of from obs.
Parameters: - () (limits) –
- () –
- name (str) –
Returns:
-
get_axes
(obs: Union[str, Iterable[str], zfit.Space] = None, as_dict: bool = False, autofill: bool = False) → Union[Tuple[int], None, Dict[str, int]]¶ Return the axes corresponding to the obs (or all if None).
Parameters: Returns: Tuple, OrderedDict
Raises: ValueError
– if the requested obs do not match with the one defined in the rangeAxesNotSpecifiedError
– If the axes in thisSpace
have not been specified.
-
get_obs_axes
(obs: Union[str, Iterable[str], zfit.Space] = None, axes: Union[int, Iterable[int]] = None)¶
-
get_reorder_indices
(obs: Union[str, Iterable[str], zfit.Space] = None, axes: Union[int, Iterable[int]] = None) → Tuple[int]¶ Indices that would order self.obs as obs respectively self.axes as axes.
Parameters: - () (axes) –
- () –
Returns:
-
get_subspace
(obs: Union[str, Iterable[str], zfit.Space] = None, axes: Union[int, Iterable[int]] = None, name: Optional[str] = None) → zfit.Space¶ Create a
Space
consisting of only a subset of the obs/axes (only one allowed).Parameters: Returns:
-
is_generator
¶
-
iter_areas
(rel: bool = False) → Tuple[float, ...][source]¶ Return the areas of each interval
Parameters: rel (bool) – If True, return the relative fraction of each interval Returns: Return type: Tuple[float]
-
iter_limits
(as_tuple: bool = True) → Union[Tuple[zfit.Space], Tuple[Tuple[Tuple[float]]], Tuple[Tuple[float]]]¶ Return the limits, either as
Space
objects or as pure limits-tuple.This makes iterating over limits easier: for limit in space.iter_limits() allows to, for example, pass limit to a function that can deal with simple limits only or if as_tuple is True the limit can be directly used to calculate something.
Example
for lower, upper in space.iter_limits(as_tuple=True): integrals = integrate(lower, upper) # calculate integral integral = sum(integrals)
Returns: Return type: List[ Space
] or List[limit,…]
-
limit1d
¶ return the tuple(lower, upper).
Returns: so lower, upper = space.limit1d
for a simple, 1 obs limit.Return type: tuple(float, float) Raises: RuntimeError
– if the conditions (n_obs or n_limits) are not satisfied.Type: Simplified limits getter for 1 obs, 1 limit only
-
limit2d
¶ return the tuple(low_obs1, low_obs2, up_obs1, up_obs2).
Returns: - so low_x, low_y, up_x, up_y = space.limit2d for a single, 2 obs limit.
- low_x is the lower limit in x, up_x is the upper limit in x etc.
Return type: tuple(float, float, float, float) Raises: RuntimeError
– if the conditions (n_obs or n_limits) are not satisfied.Type: Simplified limits for exactly 2 obs, 1 limit
-
limits
¶ Return the limits.
Returns:
-
limits1d
¶ return the tuple(low_1, …, low_n, up_1, …, up_n).
Returns: - so low_1, low_2, up_1, up_2 = space.limits1d for several, 1 obs limits.
- low_1 to up_1 is the first interval, low_2 to up_2 is the second interval etc.
Return type: tuple(float, float, ..) Raises: RuntimeError
– if the conditions (n_obs or n_limits) are not satisfied.Type: Simplified .limits for exactly 1 obs, n limits
-
lower
¶ Return the lower limits.
Returns:
-
n_limits
¶ The number of different limits.
Returns: int >= 1
-
n_obs
¶ Return the number of observables/axes.
Returns: int >= 1
-
name
¶ The name of the object.
-
obs
¶ The observables (“axes with str”)the space is defined in.
Returns:
-
obs_axes
¶
-
reorder_by_indices
(indices: Tuple[int])¶ Return a
Space
reordered by the indices.Parameters: () (indices) –
-
upper
¶ Return the upper limits.
Returns:
-
with_autofill_axes
(overwrite: bool = False) → zfit.Space¶ Return a
Space
with filled axes corresponding to range(len(n_obs)).Parameters: overwrite (bool) – If self.axes is not None, replace the axes with the autofilled ones. If axes is already set, don’t do anything if overwrite is False. Returns: Space
-
with_axes
(axes: Union[int, Iterable[int]]) → zfit.Space¶ Sort by obs and return the new instance.
Parameters: () (axes) – Returns: Space
-
with_limits
(limits: Union[Tuple[Tuple[Tuple[float, ...]]], Tuple[float, float], bool], name: Optional[str] = None) → zfit.Space¶ Return a copy of the space with the new limits (and the new name).
Parameters: - () (limits) –
- name (str) –
Returns:
-
with_obs
(obs: Union[str, Iterable[str], zfit.Space]) → zfit.Space¶ Sort by obs and return the new instance.
Parameters: () (obs) – Returns: Space
-
-
zfit.core.sample.
extended_sampling
(pdfs: Union[Iterable[zfit.core.interfaces.ZfitPDF], zfit.core.interfaces.ZfitPDF], limits: zfit.core.limits.Space) → tensorflow.python.framework.ops.Tensor[source]¶ Create a sample from extended pdfs by sampling poissonian using the yield.
Parameters: Returns: Return type: Union[tf.Tensor]