DoubleCB¶

class zfit.pdf.DoubleCB(mu, sigma, alphal, nl, alphar, nr, obs, name='DoubleCB', dtype=tf.float64)[source]

Double sided Crystal Ball shaped PDF. A combination of two CB using the mu (not a frac) on each side.

The function is defined as follows:

$f(x;\mu, \sigma, \alpha_{L}, n_{L}, \alpha_{R}, n_{R}) = \begin{cases} A_{L} \cdot (B_{L} - \frac{x - \mu}{\sigma})^{-n}, & \mbox{for }\frac{x - \mu}{\sigma} < -\alpha_{L} \newline \exp(- \frac{(x - \mu)^2}{2 \sigma^2}), & -\alpha_{L} \leqslant \mbox{for}\frac{x - \mu}{\sigma} \leqslant \alpha_{R} \newline A_{R} \cdot (B_{R} - \frac{x - \mu}{\sigma})^{-n}, & \mbox{for }\frac{x - \mu}{\sigma} > \alpha_{R} \end{cases}$

with

\begin{align}\begin{aligned}A_{L/R} = \left(\frac{n_{L/R}}{\left| \alpha_{L/R} \right|}\right)^n_{L/R} \cdot \exp\left(- \frac {\left|\alpha_{L/R} \right|^2}{2}\right)\\B_{L/R} = \frac{n_{L/R}}{\left| \alpha_{L/R} \right|} - \left| \alpha_{L/R} \right|\end{aligned}\end{align}
Parameters
• mu (~ParamTypeInput) – The mean of the gaussian

• sigma (~ParamTypeInput) – Standard deviation of the gaussian

• alphal (~ParamTypeInput) – parameter where to switch from a gaussian to the powertail on the left

• side

• nl (~ParamTypeInput) – Exponent of the powertail on the left side

• alphar (~ParamTypeInput) – parameter where to switch from a gaussian to the powertail on the right

• side

• nr (~ParamTypeInput) – Exponent of the powertail on the right side

• name (str) –

• dtype (Type) –

add_cache_deps(cache_deps, allow_non_cachable=True)

Add dependencies that render the cache invalid if they change.

Parameters
Raises

TypeError – if one of the cache_dependents is not a ZfitCachable _and_ allow_non_cachable if False.

analytic_integrate(limits, norm_range=None)

Analytical integration over function and raise Error if not possible.

Parameters
Return type

Union[float, Tensor]

Returns

The integral value

Raises
• AnalyticIntegralNotImplementedError – If no analytical integral is available (for this limits).

• NormRangeNotImplementedError – if the norm_range argument is not supported. This means that no analytical normalization is available, explicitly: the analytical integral over the limits = norm_range is not available.

apply_yield(value, norm_range=False, log=False)

If a norm_range is given, the value will be multiplied by the yield.

Parameters
Return type

Union[float, Tensor]

Returns

Numerical

as_func(norm_range=False)

Return a Function with the function model(x, norm_range=norm_range).

Parameters

norm_range (Union[Tuple[Tuple[float, …]], Tuple[float, …], bool, Space]) –

convert_sort_space(obs=None, axes=None, limits=None)

Convert the inputs (using eventually obs, axes) to ZfitSpace and sort them according to own obs.

Parameters

Returns:

Return type
copy(**override_parameters)

Creates a copy of the model.

Note: the copy model may continue to depend on the original initialization arguments.

Parameters

**override_parameters – String/value dictionary of initialization arguments to override with new value.

Return type

BasePDF

Returns

A new instance of type(self) initialized from the union

of self.parameters and override_parameters, i.e., dict(self.parameters, **override_parameters).

create_extended(yield_, name_addition='_extended')

Return an extended version of this pdf with yield yield_. The parameters are shared.

Parameters
• yield

Return type

ZfitPDF

Returns

ZfitPDF

create_projection_pdf(limits_to_integrate)

Create a PDF projection by integrating out some of the dimensions.

The new projection pdf is still fully dependent on the pdf it was created with.

Parameters

limits_to_integrate (Union[ZfitLimit, Tensor, ndarray, Iterable[float], float, Tuple[float], List[float], bool, None]) –

Return type

ZfitPDF

Returns

A pdf without the dimensions from limits_to_integrate.

create_sampler(n=None, limits=None, fixed_params=True)

Create a Sampler that acts as Data but can be resampled, also with changed parameters and n.

If limits is not specified, space is used (if the space contains limits). If n is None and the model is an extended pdf, ‘extended’ is used by default.

Parameters
Return type

Sampler

Returns

py:class:~zfit.core.data.Sampler

Raises
• NotExtendedPDFError – if ‘extended’ is chosen (implicitly by default or explicitly) as an option for n but the pdf itself is not extended.

• ValueError – if n is an invalid string option.

• InvalidArgumentError – if n is not specified and pdf is not extended.

property dtype

The dtype of the object

Return type

DType

get_cache_deps(only_floating=True)

Return a set of all independent Parameter that this object depends on.

Parameters

only_floating (bool) – If True, only return floating Parameter

Return type

OrderedSet

get_dependencies(only_floating=True)

DEPRECATED FUNCTION

Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use get_params instead if you want to retrieve the independent parameters or get_cache_deps in case you need the numerical cache dependents (advanced).

Return type

OrderedSet

get_params(floating=True, is_yield=None, extract_independent=True, only_floating=<class 'zfit.util.checks.NotSpecified'>)

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=None will return parameters that are floating as well as

parameters that are fixed.

• True: only return parameters that fulfil this criterion

• False: only return parameters that do not fulfil this criterion. E.g. floating=False will return

only parameters that are not floating.

Parameters
• floating (Optional[bool]) – if a parameter is floating, e.g. if floating() returns True

• is_yield (Optional[bool]) – 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 (Optional[bool]) – If the parameter is an independent parameter, i.e. if it is a ZfitIndependentParameter.

Return type
get_yield()

Return the yield (only for extended models).

Return type
Returns

The yield of the current model or None

property is_extended

Flag to tell whether the model is extended or not.

Return type

bool

Returns

A boolean.

log_pdf(x, norm_range=None)

Log probability density function normalized over norm_range.

Parameters
Return type

Union[float, Tensor]

Returns

A Tensor of type self.dtype.

property name

The name of the object.

Return type

str

property norm_range

Return the current normalization range. If None and the obs have limits, they are returned.

Return type
Returns

The current normalization range.

normalization(limits)

Return the normalization of the function (usually the integral over limits).

Parameters

limits (Union[Tuple[Tuple[float, …]], Tuple[float, …], bool, Space]) – The limits on where to normalize over

Return type

Union[float, Tensor]

Returns

The normalization value

numeric_integrate(limits, norm_range=None)

Numerical integration over the model.

Parameters
Return type

Union[float, Tensor]

Returns

The integral value

classmethod register_additional_repr(**kwargs)

Parameters
• keyword argument. The value has to be gettable from the instance (has to be an (any) –

• or callable method of self. (attribute) –

classmethod register_analytic_integral(func, limits=None, priority=50, *, supports_norm_range=False, supports_multiple_limits=False)

Register an analytic integral with the class.

Parameters
Return type

None

register_cacher(cacher)

Register a cacher that caches values produces by this instance; a dependent.

Parameters
classmethod register_inverse_analytic_integral(func)

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

Parameters

func (Callable) – A function with the signature func(x, params), where x is a Data object and params is a dict.

Return type

None

reset_cache_self()

Clear the cache of self and all dependent cachers.

sample(n=None, limits=None)

Sample n points within limits from the model.

If limits is not specified, space is used (if the space contains limits). If n is None and the model is an extended pdf, ‘extended’ is used by default.

Parameters
Return type

SampleData

Returns

SampleData(n_obs, n_samples)

Raises
• NotExtendedPDFError – if ‘extended’ is (implicitly by default or explicitly) chosen as an option for n but the pdf itself is not extended.

• ValueError – if n is an invalid string option.

• InvalidArgumentError – if n is not specified and pdf is not extended.

set_norm_range(norm_range)

Set the normalization range (temporarily if used with contextmanager).

Parameters

norm_range (Union[ZfitLimit, Tensor, ndarray, Iterable[float], float, Tuple[float], List[float], bool, None]) –

set_yield(value)

Make the model extended by setting a yield. If possible, prefer to use create_extended.

This does not alter the general behavior of the PDF. The pdf and integrate and similar methods will continue to return the same - normalized to 1 - values. However, not only can this parameter be accessed via get_yield, the methods ext_pdf and ext_integral provide a version of pdf and integrate respecetively that is multiplied by the yield.

These can be useful for plotting and for binned likelihoods.

Parameters

() (value) –

unnormalized_pdf(x, component_norm_range=None)

PDF “unnormalized”. Use functions for unnormalized pdfs. this is only for performance in special cases. (deprecated)

Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use pdf(norm_range=False) instead

Parameters
Return type

Union[float, Tensor]

Returns

1-dimensional tf.Tensor containing the unnormalized pdf.

update_integration_options(draws_per_dim=None, mc_sampler=None)

Set the integration options.

Parameters
• draws_per_dim – The draws for MC integration to do

• mc_sampler