Convert a histfactory declarative specification of a model in json into a Stan model. Stan is a probabilistic programming language and a set of algorithms with automatic differentiation.
We follow the histfactory specification as closely as possible and the target function (log-likelihood) should match that from pyhf up to a constant term to within a negligible numerical difference.
See the paper at [2503.22188] for more information.
pip install stanhf
At runtime, the first time you use stanhf it could install cmdstan if it isn't found. This is required to lint, validate and compile any Stan models, though stanhf can be used as a conversion tool without it.
Stanhf consists of one CLI. See
stanhf --help
for details. Try e.g.,
stanhf ./examples/normfactor.json
This converts, compiles and validates the example model. The compiled model is a cmdstan executable. You can run the usual Stan algorithms (HMC, optimization etc) through this executable.
See EXAMPLE.md for a walkthrough of how to run and analyse outpus from a compiled Stan model.