Skip to content
pure-python implementation of some (maybe someday all?) HistFactory models
Branch: master
Clone or download
kratsg and matthewfeickert Add semantic-versioning to JSON schemas (#472)
- JSON schemas are now versioned
- workspace.json explicitly requires a version attribute as this is the JSON document that gets preserved/passed around (model.json and measurement.json do not explicitly require it)
- utils.validate and utils.load_schema are updated to handle versioning as well
Latest commit ca1d373 May 7, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add version info through __version__ (#304) Oct 10, 2018
binder Remove editable flag for Binder to avoid PEP 517 issue (#463) May 7, 2019
docker Add Dockerfile (#225) Sep 4, 2018
docs Remove use of --no-use-pep517 flag from pip install with pip v19.1.1+ ( May 7, 2019
examples/experiments Edward (#110) Aug 17, 2018
pyhf Add semantic-versioning to JSON schemas (#472) May 8, 2019
tests Add configurable optimizer (and options) through pyhf cls CLI (#403) May 2, 2019
validation add support for shapesys import from xml (#402) Feb 27, 2019
.ackrc Add additional pdf information to aid with refactoring (#305) Oct 12, 2018
.bumpversion.cfg Bump version: 0.0.17 → 0.1.0 Apr 13, 2019
.git_archival.txt Finish adding deploy testing with TestPyPI (#436) Apr 11, 2019
.gitattributes Finish adding deploy testing with TestPyPI (#436) Apr 11, 2019
.gitignore Start setting up documentation more (#157) May 6, 2018
.pre-commit-config.yaml Use Black code style (#322) Oct 21, 2018
.travis.yml Remove use of --no-use-pep517 flag from pip install with pip v19.1.1+ ( May 7, 2019
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Jan 26, 2018
CONTRIBUTING.md Install with --ignore-installed to ensure proper NumPy (#237) Sep 6, 2018
LICENSE Create LICENSE Jan 26, 2018
MANIFEST.in Add /schemas to documentation (#452) Apr 26, 2019
README.md Use consistent column alignment in Markdown tables (#438) Apr 12, 2019
pyproject.toml Use --no-use-pep517 flag for editable mode with pyproject.toml (#455) Apr 25, 2019
pytest.ini Updates the backend to get ready for full refactor (#287) Oct 1, 2018
setup.cfg Finish adding deploy testing with TestPyPI (#436) Apr 11, 2019
setup.py Add configurable optimizer (and options) through pyhf cls CLI (#403) May 2, 2019

README.md

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

DOI

Build Status Docker Automated Coverage Status Code Health CodeFactor Code style: black

Docs Binder

PyPI version Supported Python versionss Docker Stars Docker Pulls

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
>>> pdf = pyhf.simplemodels.hepdata_like(signal_data=[12.0, 11.0], bkg_data=[50.0, 52.0], bkg_uncerts=[3.0, 7.0])
>>> CLs_obs, CLs_exp = pyhf.utils.hypotest(1.0, [51, 48] + pdf.config.auxdata, pdf, return_expected=True)
>>> print('Observed: {}, Expected: {}'.format(CLs_obs, CLs_exp))
Observed: [0.05290116], Expected: [0.06445521]

What does it support

Implemented variations:

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

Computational Backends:

  • NumPy
  • PyTorch
  • TensorFlow
  • MXNet

Available Optimizers

NumPy Tensorflow PyTorch MxNet
SLSQP (scipy.optimize) Newton's Method (autodiff) Newton's Method (autodiff) N/A
MINUIT (iminuit) . . .

Todo

  • 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 from PyPI with the NumPy backend run

pip install pyhf

and to install pyhf with additional backends run

pip install pyhf[tensorflow,torch,mxnet]

or a subset of the options.

To uninstall run

pip uninstall pyhf

Authors

Please check the contribution statistics for a list of contributors

You can’t perform that action at this time.