HistogramPDF#
- class zfit.pdf.HistogramPDF(data, extended=None, norm=None, name='HistogramPDF')[source]#
Bases:
zfit.core.binnedpdf.BaseBinnedPDFV1
Binned PDF resembling a histogram.
Simple histogram PDF that can be used to model a histogram as a PDF.
- Parameters
data (
Union
[PlottableHistogram
,Iterable
[PlottableHistogram
]]) – Histogram to be used as PDF.extended (
Union
[bool
,TypeVar
(ParamTypeInput
, zfit.core.interfaces.ZfitParameter,Union
[int
,float
,complex
,Tensor
, zfit.core.interfaces.ZfitParameter]),None
]) – The overall yield of the PDF. If this is parameter-like, it will be used as the yield, the expected number of events, and the PDF will be extended. An extended PDF has additional functionality, such as theext_*
methods and thecounts
(for binned PDFs).IfTrue
, the PDF will be extended automatically if the PDF is extended using the total number of events in the histogram. This is the default.norm (
Optional
[zfit.Space]) – Normalization of the PDF. By default, this is the same as the default space of the PDF.name (
str
) – Human-readable name or label of the PDF for better identification. Has no programmatical functional purpose as identification.
- add_cache_deps(cache_deps, allow_non_cachable=True)#
Add dependencies that render the cache invalid if they change.
- Parameters
cache_deps (
Union
[zfit.core.interfaces.ZfitGraphCachable,Iterable
[zfit.core.interfaces.ZfitGraphCachable]]) –allow_non_cachable (
bool
) – IfTrue
, allowcache_dependents
to be non-cachables. IfFalse
, anycache_dependents
that is not aZfitGraphCachable
will raise an error.
- Raises
TypeError – if one of the
cache_dependents
is not aZfitGraphCachable
_and_allow_non_cachable
ifFalse
.
- property dtype: tensorflow.python.framework.dtypes.DType#
The dtype of the object.
- Return type
DType
- ext_integrate(limits, norm=None, *, norm_range=None, options=None)#
Extended integral of the PDF, i.e. the expected counts.
- Parameters
limits (
Union
[Tuple
[Tuple
[float
,...
]],Tuple
[float
,...
],bool
,Space
]) – Limits of the integration.norm (
Union
[Tuple
[Tuple
[float
,...
]],Tuple
[float
,...
],bool
,Space
,None
]) – Normalization of the integration. By default, this is the same as the default space of the PDF.False
means no normalization and returns the unnormed integral.options –
Options for the integration. Additional options for the integration. Currently supported options are: - type: one of (
bins
)This hints that bins are integrated. A method that is vectorizable, non-dynamic and therefore less suitable for complicated functions is chosen.
Returns:
- Return type
Union
[float
,Tensor
]
- ext_pdf(x, norm=None, *, norm_range=None)#
DEPRECATED FUNCTION ARGUMENTS
Warning: SOME ARGUMENTS ARE DEPRECATED:
(norm_range)
. They will be removed in a future version. Instructions for updating: Usenorm
instead.- Return type
Union
[float
,Tensor
]
- get_cache_deps(only_floating=True)#
Return a set of all independent
Parameter
that this object depends on.- Parameters
only_floating – If
True
, only return floatingParameter
- 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 orget_cache_deps
in case you need the numerical cache dependents (advanced).
- 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.
- None: do not filter on this. E.g.
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.
- False: only return parameters that do not fulfil this criterion. E.g.
- Parameters
floating (bool | None) – if a parameter is floating, e.g. if
floating()
returnsTrue
is_yield (bool | None) – 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 (bool | None) – If the parameter is an independent parameter, i.e. if it is a
ZfitIndependentParameter
.
- Return type
set[ZfitParameter]
- property name: str#
The name of the object.
- Return type
str
- property norm_range#
DEPRECATED FUNCTION
Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: use
norm
instead.
- pdf(x, norm=None, *, norm_range=None)#
Probability density function, evaluated at
x
or in the bins ofx
(deprecated arguments)Warning: SOME ARGUMENTS ARE DEPRECATED:
(norm_range)
. They will be removed in a future version. Instructions for updating: Usenorm
instead.- Parameters
x (
Union
[float
,Tensor
]) – values to evaluate the PDF at. If this is aZfitBinnedData
-like object, a histogram of densities will be returned. If x is aZfitUnbinnedData
-like object, the densities will be evaluated at the points ofx
.norm (
Union
[Tuple
[Tuple
[float
,...
]],Tuple
[float
,...
],bool
,Space
,None
]) – Normalization of the function. By default, this is thenorm
of the PDF (which by default is the same as the space of the PDF).
- Returns
probability density
- Return type
Array-like
- register_cacher(cacher)#
Register a
cacher
that caches values produces by this instance; a dependent.- Parameters
cacher (
Union
[zfit.core.interfaces.ZfitGraphCachable,Iterable
[zfit.core.interfaces.ZfitGraphCachable]]) –
- reset_cache_self()#
Clear the cache of self and all dependent cachers.
- sample(n=None, limits=None)#
Draw a random binned sample from the PDF.
- Parameters
n (
Optional
[int
]) – Number of samples to draw. For an extended PDF, the argument is optional and will be the poisson-fluctuated expected number of events, i.e. the yield.limits (
Union
[Tuple
[Tuple
[float
,...
]],Tuple
[float
,...
],bool
,Space
,None
]) – Limits of the sampling. By default, this is the same as the default space of the PDF.
- Returns
Sampled dataset
- Return type
ZfitBinnedData
- to_binneddata(**kwargs)#
Create an Asimov dataset as
BinnedData
using eithercounts
(for extended) orrel_counts
- Parameters
() (**kwargs) – arguments to
counts
orrel_counts
.- Returns
Binned data representing the Asimov dataset of this PDF.
- Return type
- to_hist(**kwargs)#
Create an Asimov histogram as
Hist
using eithercounts
(for extended) orrel_counts
.- Parameters
() (**kwargs) – arguments to
counts
orrel_counts
.- Returns
Histogram representing the Asimov dataset of this PDF.
- Return type
hist.Hist
- values(*, var=None)#
Histogram values that are either the counts or the normalized counts.
If the PDF is extended, the counts are returned, otherwise the normalized counts are returned.
- Returns
Histogram values
- Return type
ZfitBinnedData