Skip to content
/ pyhf Public
forked from scikit-hep/pyhf

pure-python implementation of some (maybe someday all?) HistFactory models

License

Notifications You must be signed in to change notification settings

SEBrown/pyhf

 
 

Repository files navigation

pure-python fitting/limit-setting/interval estimation HistFactory-style

DOI Build Status Coverage Status Code Health Docs PyPI version Binder

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.

Hello World

>>> 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]

What does it support

Implemented variations:

  • HistoSys
  • OverallSys
  • ShapeSys
  • NormFactor
  • Multiple Channels
  • Import from XML + ROOT via uproot
  • ShapeFactor
  • StatError

Computational Backends:

  • NumPy
  • PyTorch
  • TensorFlow
  • MXNet

Todo

  • Lumi Uncertainty
  • StatConfig
  • Non-asymptotic calculators

results obtained from this package are validated against output computed from HistFactory workspaces

A one bin example

nobs = 55, b = 50, db = 7, nom_sig = 10.

manual

manual

A two bin example

bin 1: nobs = 100, b = 100, db = 15., nom_sig = 30.
bin 2: nobs = 145, b = 150, db = 20., nom_sig = 45.

manual

manual

Installation

To install pyhf run

python setup.py install

To uninstall run

pip uninstall pyhf

Authors

Please check the contribution statistics for a list of contributors

About

pure-python implementation of some (maybe someday all?) HistFactory models

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%