BinnedData#
- class zfit.data.BinnedData(*, holder)[source]#
Bases:
ZfitBinnedDataCreate a binned data object from a
BinnedHolder.Prefer to use the constructors
from_*ofBinnedDatalikefrom_hist(),from_tensor()orfrom_unbinned().- Parameters
holder –
- classmethod from_tensor(space, values, variances=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 thatvalueshave been drawn from a Poisson distribution. Follows the definition of the Unified Histogram Interface (UHI).
- Return type
- classmethod from_unbinned(space, data)[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
histhistogram.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
- 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.