interfaces

class zfit.core.interfaces.ZfitConstraint[source]

Bases: abc.ABC

value()[source]
class zfit.core.interfaces.ZfitData[source]

Bases: zfit.core.interfaces.ZfitDimensional

axes

Return the axes.

copy(deep: bool = False, **overwrite_params) → zfit.core.interfaces.ZfitObject
n_obs

Return the number of observables.

name

Name prepended to all ops created by this model.

obs

Return the observables.

sort_by_axes(axes, allow_superset: bool = False)[source]
sort_by_obs(obs, allow_superset: bool = False)[source]
space

Return the Space object that defines the dimensionality of the object.

value(obs: List[str] = None) → Union[float, tensorflow.python.framework.ops.Tensor][source]
weights
class zfit.core.interfaces.ZfitDependentsMixin[source]

Bases: object

get_dependents(only_floating: bool = True) -> OrderedSet(['z', 'f', 'i', 't', '.', 'P', 'a', 'r', 'm', 'e'])[source]
class zfit.core.interfaces.ZfitDimensional[source]

Bases: zfit.core.interfaces.ZfitObject

axes

Return the axes.

copy(deep: bool = False, **overwrite_params) → zfit.core.interfaces.ZfitObject
n_obs

Return the number of observables.

name

Name prepended to all ops created by this model.

obs

Return the observables.

space

Return the Space object that defines the dimensionality of the object.

class zfit.core.interfaces.ZfitFunc[source]

Bases: zfit.core.interfaces.ZfitModel

as_pdf()[source]
axes

Return the axes.

copy(deep: bool = False, **overwrite_params) → zfit.core.interfaces.ZfitObject
dtype

The DType of Tensor`s handled by this `model.

func(x: Union[float, tensorflow.python.framework.ops.Tensor], name: str = 'value') → Union[float, tensorflow.python.framework.ops.Tensor][source]
get_dependents(only_floating: bool = True) -> OrderedSet(['z', 'f', 'i', 't', '.', 'P', 'a', 'r', 'm', 'e'])
get_params(only_floating: bool = False, names: Union[str, List[str], None] = None) → List[zfit.core.interfaces.ZfitParameter]
integrate(limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool], norm_range: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, name: str = 'integrate') → Union[float, tensorflow.python.framework.ops.Tensor]

Integrate the function over limits (normalized over norm_range if not False).

Parameters:
  • limits (tuple, Space) – the limits to integrate over
  • norm_range (tuple, Space) – the limits to normalize over or False to integrate the unnormalized probability
  • name (str) –
Returns:

the integral value

Return type:

Tensor

n_obs

Return the number of observables.

name

Name prepended to all ops created by this model.

obs

Return the observables.

params
partial_integrate(x: Union[float, tensorflow.python.framework.ops.Tensor], limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool], norm_range: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, name: str = 'partial_integrate') → Union[float, tensorflow.python.framework.ops.Tensor]

Partially integrate the function over the limits and evaluate it at x.

Dimension of limits and x have to add up to the full dimension and be therefore equal to the dimensions of norm_range (if not False)

Parameters:
  • x (numerical) – The value at which the partially integrated function will be evaluated
  • limits (tuple, Space) – the limits to integrate over. Can contain only some axes
  • norm_range (tuple, Space, False) – the limits to normalize over. Has to have all axes
  • name (str) –
Returns:

the value of the partially integrated function evaluated at x.

Return type:

Tensor

classmethod register_analytic_integral(func: Callable, limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, priority: int = 50, *, supports_norm_range: bool = False, supports_multiple_limits: bool = False)

Register an analytic integral with the class.

Parameters:

Returns:

classmethod register_inverse_analytic_integral(func: Callable)

Register an inverse analytical integral, the inverse (unnormalized) cdf.

Parameters:() (func) –
sample(n: int, limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, name: str = 'sample') → Union[float, tensorflow.python.framework.ops.Tensor]

Sample n points within limits from the model.

Parameters:
  • n (int) – The number of samples to be generated
  • limits (tuple, Space) – In which region to sample in
  • name (str) –
Returns:

Tensor(n_obs, n_samples)

space

Return the Space object that defines the dimensionality of the object.

update_integration_options(*args, **kwargs)
class zfit.core.interfaces.ZfitFunctorMixin[source]

Bases: object

get_models() → List[zfit.core.interfaces.ZfitModel][source]
models
class zfit.core.interfaces.ZfitLoss[source]

Bases: zfit.core.interfaces.ZfitObject, zfit.core.interfaces.ZfitDependentsMixin

add_constraints(constraints: List[tensorflow.python.framework.ops.Tensor])[source]
copy(deep: bool = False, **overwrite_params) → zfit.core.interfaces.ZfitObject
data
errordef
fit_range
get_dependents(only_floating: bool = True) -> OrderedSet(['z', 'f', 'i', 't', '.', 'P', 'a', 'r', 'm', 'e'])
gradients(params: Union[zfit.core.interfaces.ZfitParameter, int, float, complex, tensorflow.python.framework.ops.Tensor] = None) → List[tensorflow.python.framework.ops.Tensor][source]
model
name

Name prepended to all ops created by this model.

value() → Union[tensorflow.python.framework.ops.Tensor, numpy.array][source]
class zfit.core.interfaces.ZfitModel[source]

Bases: zfit.core.interfaces.ZfitNumeric, zfit.core.interfaces.ZfitDimensional

axes

Return the axes.

copy(deep: bool = False, **overwrite_params) → zfit.core.interfaces.ZfitObject
dtype

The DType of Tensor`s handled by this `model.

get_dependents(only_floating: bool = True) -> OrderedSet(['z', 'f', 'i', 't', '.', 'P', 'a', 'r', 'm', 'e'])
get_params(only_floating: bool = False, names: Union[str, List[str], None] = None) → List[zfit.core.interfaces.ZfitParameter]
integrate(limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool], norm_range: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, name: str = 'integrate') → Union[float, tensorflow.python.framework.ops.Tensor][source]

Integrate the function over limits (normalized over norm_range if not False).

Parameters:
  • limits (tuple, Space) – the limits to integrate over
  • norm_range (tuple, Space) – the limits to normalize over or False to integrate the unnormalized probability
  • name (str) –
Returns:

the integral value

Return type:

Tensor

n_obs

Return the number of observables.

name

Name prepended to all ops created by this model.

obs

Return the observables.

params
partial_integrate(x: Union[float, tensorflow.python.framework.ops.Tensor], limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool], norm_range: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, name: str = 'partial_integrate') → Union[float, tensorflow.python.framework.ops.Tensor][source]

Partially integrate the function over the limits and evaluate it at x.

Dimension of limits and x have to add up to the full dimension and be therefore equal to the dimensions of norm_range (if not False)

Parameters:
  • x (numerical) – The value at which the partially integrated function will be evaluated
  • limits (tuple, Space) – the limits to integrate over. Can contain only some axes
  • norm_range (tuple, Space, False) – the limits to normalize over. Has to have all axes
  • name (str) –
Returns:

the value of the partially integrated function evaluated at x.

Return type:

Tensor

classmethod register_analytic_integral(func: Callable, limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, priority: int = 50, *, supports_norm_range: bool = False, supports_multiple_limits: bool = False)[source]

Register an analytic integral with the class.

Parameters:

Returns:

classmethod register_inverse_analytic_integral(func: Callable)[source]

Register an inverse analytical integral, the inverse (unnormalized) cdf.

Parameters:() (func) –
sample(n: int, limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, name: str = 'sample') → Union[float, tensorflow.python.framework.ops.Tensor][source]

Sample n points within limits from the model.

Parameters:
  • n (int) – The number of samples to be generated
  • limits (tuple, Space) – In which region to sample in
  • name (str) –
Returns:

Tensor(n_obs, n_samples)

space

Return the Space object that defines the dimensionality of the object.

update_integration_options(*args, **kwargs)[source]
class zfit.core.interfaces.ZfitNumeric[source]

Bases: zfit.core.interfaces.ZfitDependentsMixin, zfit.core.interfaces.ZfitObject

copy(deep: bool = False, **overwrite_params) → zfit.core.interfaces.ZfitObject
dtype

The DType of Tensor`s handled by this `model.

get_dependents(only_floating: bool = True) -> OrderedSet(['z', 'f', 'i', 't', '.', 'P', 'a', 'r', 'm', 'e'])
get_params(only_floating: bool = False, names: Union[str, List[str], None] = None) → List[zfit.core.interfaces.ZfitParameter][source]
name

Name prepended to all ops created by this model.

params
class zfit.core.interfaces.ZfitObject[source]

Bases: abc.ABC

copy(deep: bool = False, **overwrite_params) → zfit.core.interfaces.ZfitObject[source]
name

Name prepended to all ops created by this model.

class zfit.core.interfaces.ZfitPDF[source]

Bases: zfit.core.interfaces.ZfitModel

as_func(norm_range: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = False)[source]
axes

Return the axes.

copy(deep: bool = False, **overwrite_params) → zfit.core.interfaces.ZfitObject
create_extended(yield_: Union[zfit.core.interfaces.ZfitParameter, int, float, complex, tensorflow.python.framework.ops.Tensor]) → zfit.core.interfaces.ZfitPDF[source]
dtype

The DType of Tensor`s handled by this `model.

get_dependents(only_floating: bool = True) -> OrderedSet(['z', 'f', 'i', 't', '.', 'P', 'a', 'r', 'm', 'e'])
get_params(only_floating: bool = False, names: Union[str, List[str], None] = None) → List[zfit.core.interfaces.ZfitParameter]
get_yield() → Optional[zfit.core.interfaces.ZfitParameter][source]
integrate(limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool], norm_range: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, name: str = 'integrate') → Union[float, tensorflow.python.framework.ops.Tensor]

Integrate the function over limits (normalized over norm_range if not False).

Parameters:
  • limits (tuple, Space) – the limits to integrate over
  • norm_range (tuple, Space) – the limits to normalize over or False to integrate the unnormalized probability
  • name (str) –
Returns:

the integral value

Return type:

Tensor

is_extended
n_obs

Return the number of observables.

name

Name prepended to all ops created by this model.

normalization(limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool], name: str = 'normalization') → Union[tensorflow.python.framework.ops.Tensor, numpy.array][source]
obs

Return the observables.

params
partial_integrate(x: Union[float, tensorflow.python.framework.ops.Tensor], limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool], norm_range: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, name: str = 'partial_integrate') → Union[float, tensorflow.python.framework.ops.Tensor]

Partially integrate the function over the limits and evaluate it at x.

Dimension of limits and x have to add up to the full dimension and be therefore equal to the dimensions of norm_range (if not False)

Parameters:
  • x (numerical) – The value at which the partially integrated function will be evaluated
  • limits (tuple, Space) – the limits to integrate over. Can contain only some axes
  • norm_range (tuple, Space, False) – the limits to normalize over. Has to have all axes
  • name (str) –
Returns:

the value of the partially integrated function evaluated at x.

Return type:

Tensor

pdf(x: Union[float, tensorflow.python.framework.ops.Tensor], norm_range: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, name: str = 'model') → Union[float, tensorflow.python.framework.ops.Tensor][source]
classmethod register_analytic_integral(func: Callable, limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, priority: int = 50, *, supports_norm_range: bool = False, supports_multiple_limits: bool = False)

Register an analytic integral with the class.

Parameters:

Returns:

classmethod register_inverse_analytic_integral(func: Callable)

Register an inverse analytical integral, the inverse (unnormalized) cdf.

Parameters:() (func) –
sample(n: int, limits: Union[Tuple[Tuple[float, ...]], Tuple[float, ...], bool] = None, name: str = 'sample') → Union[float, tensorflow.python.framework.ops.Tensor]

Sample n points within limits from the model.

Parameters:
  • n (int) – The number of samples to be generated
  • limits (tuple, Space) – In which region to sample in
  • name (str) –
Returns:

Tensor(n_obs, n_samples)

set_norm_range()[source]
space

Return the Space object that defines the dimensionality of the object.

update_integration_options(*args, **kwargs)
class zfit.core.interfaces.ZfitParameter[source]

Bases: zfit.core.interfaces.ZfitNumeric

copy(deep: bool = False, **overwrite_params) → zfit.core.interfaces.ZfitObject
dtype

The DType of Tensor`s handled by this `model.

floating
get_dependents(only_floating: bool = True) -> OrderedSet(['z', 'f', 'i', 't', '.', 'P', 'a', 'r', 'm', 'e'])
get_params(only_floating: bool = False, names: Union[str, List[str], None] = None) → List[zfit.core.interfaces.ZfitParameter]
independent
name

Name prepended to all ops created by this model.

params
value() → tensorflow.python.framework.ops.Tensor[source]
class zfit.core.interfaces.ZfitSpace[source]

Bases: zfit.core.interfaces.ZfitObject

area() → float[source]

Return the total area of all the limits and axes. Useful, for example, for MC integration.

axes
copy(deep: bool = False, **overwrite_params) → zfit.core.interfaces.ZfitObject
get_axes(obs: Union[str, Tuple[str, ...]] = None, as_dict: bool = True)[source]

Return the axes number of the observable if available (set by axes_by_obs).

Raises:AxesNotUnambiguousError – In case
get_subspace(obs: Union[str, Iterable[str], zfit.Space] = None, axes=None, name=None) → zfit.core.limits.Space[source]
iter_areas(rel: bool = False) → Tuple[float, ...][source]

Return the areas of each limit.

iter_limits()[source]

Iterate through the limits by returning several observables/(lower, upper)-tuples.

limits

Return the tuple(lower, upper).

lower

Return the lower limits.

n_limits

Return the number of limits.

n_obs

Return the number of observables (axis).

name

Name prepended to all ops created by this model.

obs

Return a list of the observable names.

upper

Return the upper limits.

with_autofill_axes(overwrite: bool)[source]

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)[source]

Sort by obs and return the new instance.

Parameters:() (axes) –
Returns:Space
with_limits(limits, name)[source]

Return a copy of the space with the new limits (and the new name).

Parameters:
  • () (limits) –
  • name (str) –
Returns:

Space

with_obs(obs)[source]

Sort by obs and return the new instance.

Parameters:() (obs) –
Returns:Space