BinnedData#
- class zfit.data.BinnedData(*, holder, use_hash=None, name=None, label=None)[source]#
Bases:
ZfitBinnedData
Create a binned data object from a
BinnedHolder
.Prefer to use the constructors
from_*
ofBinnedData
likefrom_hist()
,from_tensor()
orfrom_unbinned()
.- Parameters:
holder
- with_variances(variances)[source]#
Return a new binned data object with updated variances.
- Parameters:
variances (
array
) – The new variances- Return type:
- enable_hashing()[source]#
Enable hashing for this data object if it was disabled.
A hash allows some objects to be cached and reused. If a hash is enabled, the data object will be hashed and the hash _can_ be used for caching. This can speedup various objects, however, it maybe doesn’t have an effect at all. For example, if an object was already called before with the data object, the hash will probably not be used, as the object is already compiled.
- classmethod from_tensor(space, values, variances=None, name=None, label=None, use_hash=None)[source]#
Create a binned dataset defined in space where values are considered to be the counts.
- Parameters:
space (ZfitSpace) – Binned space of the data. The space is used to define the binning and the limits of the data.
values (znp.array) – Corresponds to the counts of the histogram. Follows the definition of the Unified Histogram Interface (UHI).
variances (znp.array | None) –
Corresponds to the uncertainties of the histogram. If
True
, the uncertainties are created assuming thatvalues
have been drawn from a Poisson distribution. Follows the definition of the Unified Histogram Interface (UHI).
- Return type:
BinnedData
- classmethod from_unbinned(space, data, *, use_hash=None, name=None, label=None)[source]#
Convert an unbinned dataset to a binned dataset.
- Parameters:
space (
ZfitSpace
) – Binned space of the data. The space is used to define the binning and the limits of the data.data (
ZfitData
) – Unbinned data to be converted to binned data
- Returns:
The binned data
- Return type:
ZfitBinnedData
- classmethod from_hist(h)[source]#
Create a binned dataset from a
hist
histogram.A histogram (following the UHI definition) with named axes.
- Parameters:
h (
NamedHist
) – A NamedHist. The axes will be used as the binning in zfit.- Return type:
- with_obs(obs)[source]#
Return a subset of the data in the ordering of obs.
- Parameters:
obs (ztyping.ObsTypeInput) – Which obs to return
- Return type:
BinnedData
- to_hist()[source]#
Convert the binned data to a
NamedHist
.While a binned data object can be used inside zfit (PDFs,…), it lacks many convenience features that the hist library offers, such as plots.
- Return type:
- values()[source]#
Values of the histogram as an ndim array.
Compared to
hist
, zfit does not make a difference between a view and a copy; tensors are immutable. This distinction is made in the traced function by the compilation backend.- Return type:
array
- Returns:
Tensor of shape (nbins0, nbins1, …) with nbins the number of bins in each observable.
- variances()[source]#
Variances, if available, of the histogram as an ndim array.
Compared to
hist
, zfit does not make a difference between a view and a copy; tensors are immutable. This distinction is made in the traced function by the compilation backend.- Return type:
None | znp.array
- Returns:
Tensor of shape (nbins0, nbins1, …) with nbins the number of bins in each observable.
- counts()[source]#
Effective counts of the histogram as a ndim array.
Compared to
hist
, zfit does not make a difference between a view and a copy; tensors are immutable. This distinction is made in the traced function by the compilation backend.- Returns:
Tensor of shape (nbins0, nbins1, …) with nbins the number of bins in each observable.