Skip to main content

relaxed logo

GitHub Workflow Status Read the Docs Read the Docs Zenodo DOI Binder

Provides differentiable ("relaxed") versions of common operations in high-energy physics.

Based on jax. Where possible, function APIs try to mimic their commonly used counterparts, e.g. fitting and hypothesis testing in pyhf.

Currently implemented:

  • basic operations:
    • relaxed.hist: histograms via kernel density estimation (tunable bandwidth).
    • relaxed.cut: approximates a hard cut with a sigmoid function (tunable slope).
  • fitting routines:
    • relaxed.mle.fit: global MLE fit.
    • relaxed.mle.fixed_poi_fit: constrained fit given a value of a parameter of interest.
  • inference:
    • relaxed.infer.hypotest: hypothesis test based on the profile likelihood. Supports test statistics for both limit setting (q) and discovery (q_0).
    • relaxed.fisher_info: the fisher information matrix (of a pyhf-type model).
    • relaxed.cramer_rao_uncert: inverts the fisher information matrix to provide uncertainties valid through the Cramér-Rao bound.
  • metrics:
    • relaxed.metrics.gaussianity: an experimental metric that quantifies the mean-squared difference of a likelihood function with respect to its gaussian approximation (covariance calculated using the Cramér-Rao bound above).
    • relaxed.metrics.asimov_sig: easy access to the (single- and multi-bin) stat-only expected significance.

We're maintaining a list of desired differentiable operations in list_of_operations.md (thanks to @cranmer) -- feel free to take inspiration or contribute with a PR if there's one you can handle :)

Install

In your virtual environment:

python3 -m pip install relaxed

Examples

Binder <- Click here to start playing with our examples straight away (thanks to Binder)!

If you'd rather run the example notebooks locally from examples/, you can clone the repository, then:

python3 -m venv venv  # or virtualenv
source venv/bin/activate
pip install --upgrade pip setuptools wheel
pip install relaxed
cd examples
pip install -r requirements.txt

Then launch jupyter through your preferred medium (vscode, jupyterlab, etc.), making sure to use this virtual env as your kernel (e.g. you can pip install and run jupyter lab in this env).

Sharp bits

For serious use with pyhf, e.g. in a neos-type workflow, it is temporarily recommended to install pyhf using a specific branch that is designed to be differentiable with respect to model construction:

python3 -m pip install git+http://github.com/scikit-hep/pyhf.git@make_difffable_model_ctor

We plan to merge this into pyhf when it's stable, and will then drop this instruction :)

Cite

If you use relaxed, please cite us! You should be able to do that from the github UI (top-right, under 'cite this repository'), but if not, see our Zenodo DOI or our CITATION.cff.

Acknowledgments

Big thanks to all the developers of the main packages we use (jax, pyhf, jaxopt). Thanks also to @dfm for the README header inspiration ;)

Metadata

Release files for relaxed 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for relaxed 0.4.0
File Size Uploaded Provenance Actions
relaxed-0.4.0.tar.gz 517.4 kB Without provenance Details for relaxed-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for relaxed 0.4.0
File Interpreter ABI Platform Actions
relaxed-0.4.0-py3-none-any.whl Python 3 none any Details for relaxed-0.4.0-py3-none-any.whl

Total release size: 529.3 kB

Release files / relaxed-0.4.0.tar.gz

Download URL relaxed-0.4.0.tar.gz
Size 517.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ebbb336194fffed12e4850e7e60b8762e0ec92a031dba476dca0eddfd3fb4d96
BLAKE2b-256 checksum
How to use checksums
8e653eda46da10c14d9817fbff06c2fbd72389130cc956811a8f4b9a7b851d99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / relaxed-0.4.0-py3-none-any.whl

Download URL relaxed-0.4.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd0a2bfca848ba71b2c722dbf1a9b72d30096a1cd8c576182d3f0a8c1fd9b3a2
BLAKE2b-256 checksum
How to use checksums
b33ba4668140af1e4a4699eebbcae648836c07a69b1d446d62eaf77a624b1bd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Security for relaxed 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page