The HistFactory p.d.f. template [CERN-OPEN-2012-016] is per-se independent of its implementation in ROOT and sometimes, it's useful to be able to run statistical analysis outside of ROOT, RooFit, RooStats framework.
This repo is a pure-python implementation of that statistical model for multi-bin histogram-based analysis and its interval estimation is based on the asymptotic formulas of "Asymptotic formulae for likelihood-based tests of new physics" [arxiv:1007.1727]. The aim is also to support modern computational graph libraries such as PyTorch and Tensorflow in order to make use of features such as autodifferentiation and GPU acceleration.
>>> import pyhf
>>> import pyhf.simplemodels
>>> p = pyhf.simplemodels.hepdata_like(signal_data=[12.,11.], bkg_data=[50.,52.], bkg_uncerts=[3.,7.])
>>> *_, CLs_obs,CLs_exp = pyhf.runOnePoint(1.0, [51, 48] + p.config.auxdata, p)
>>> print('obs: {} exp: {}'.format(CLs_obs, CLs_exp[2]))
obs: [0.05290116] exp: [0.06445521]
Implemented variations:
- HistoSys
- OverallSys
- ShapeSys
- NormFactor
- Multiple Channels
- Import from XML + ROOT via
uproot
- ShapeFactor
- StatError
Computational Backends:
- NumPy
- PyTorch
- TensorFlow
- MXNet
- Lumi Uncertainty
- StatConfig
- Non-asymptotic calculators
results obtained from this package are validated against output computed from HistFactory workspaces
nobs = 55, b = 50, db = 7, nom_sig = 10.
bin 1: nobs = 100, b = 100, db = 15., nom_sig = 30.
bin 2: nobs = 145, b = 150, db = 20., nom_sig = 45.
To install pyhf
run
python setup.py install
To uninstall run
pip uninstall pyhf
Please check the contribution statistics for a list of contributors