Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

pyhfcorr

Treating correlated uncertainties with pyhf

pyhf is based on the HistFactory statistical model. This is a very general tool for statistical inference of binned data.

One feature that is not included in pyhf is the correct treatment of arbitrarily correlated uncertainties. The current implementation features only fully (de)correlated uncertainties.

The use of this package is to add the option for arbitrarily correlated uncertainties, by a simple pre-processing step of the pyhf model. The mathematical background used is simple singular value decomposition (SVD) (also see below).

To account for correlations between parameters, one simply adds a correlation field to the pyhf model. Here we specify a name, which will be the new modifier name, the correlated variables vars, and the correlation matrix corr:

spec = {
    "channels" : ...,
    "correlations": [
        {
            "name": "corr_1_2",
            "vars": ["unc1", "unc2"],
            "corr": [[1.0, 0.5], [0.5, 1.]],
        }
    ]
}

By pre-processing the model specification, we obtain a new specification, which is now pyhf compatible and has the correlation correctly implemented:

new_spec = pyhfcorr.decorrelate.decorrelate(spec)

Singular value decomposition

We can decompose a correlation matrix $C$ as

$$ C = U S^2 U^H = USSU^H = (US)(US)^H,$$

where $U$ is a unitary transformation matrix, $UU^H=1$ and $S$ is the diagonal matrix of standard deviations, $S=S^H$.

The geometrical interpretation of this is, that by applying the transformation $(US)^{-1}$ to correlated data results in an uncorrelated data-set with unity standard deviation.

The rotation $U^{-1} = U^H$ rotates points to a new coordinate system, where correlations between the dimensions vanish. In this rotated coordinate system, $S^{-1}$ scales the dimensions accordingly.

An illustration for a 2-dimensional random multivariate dataset $x$ with correlation coefficient $\rho=0.8$ is shown here:

pca illustration

Metadata

Release files for pyhfcorr 0.1.dev39

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

Source distribution (sdist)

Source distribution for pyhfcorr 0.1.dev39
File Size Uploaded
pyhfcorr-0.1.dev39.tar.gz 6.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyhfcorr 0.1.dev39
File Interpreter ABI Platform
pyhfcorr-0.1.dev39-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 kB

Release files / pyhfcorr-0.1.dev39.tar.gz

Download URL pyhfcorr-0.1.dev39.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5c8623babaa2ccd80e046ece11a354a1b830f31b43aa13229f02023d6a238552
BLAKE2b-256 checksum
How to use checksums
6e641d06858fb115a7df49fc43dfd9e543a127286c7492f8bbc06d9b9f8916e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.0

Release files / pyhfcorr-0.1.dev39-py3-none-any.whl

Download URL pyhfcorr-0.1.dev39-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5021652121d0856c32787c4e7c31c313637d9961dac3a3f8cea07771d3956a36
BLAKE2b-256 checksum
How to use checksums
e740e3b85aacb60637f213107e317d3d500f34c6b9488d54bb3d708d072399b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.0

Release history Release notifications | RSS feed

This release

0.1.dev39 This release

2 release files

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