AsymptoticTestStatDistribution#

class pyhf.infer.calculators.AsymptoticTestStatDistribution(shift, cutoff=-inf)[source]#

Bases: object

The distribution the test statistic in the asymptotic case.

Note: These distributions are in μ^/σ space. In the ROOT implementation the same sigma is assumed for both hypotheses and p-values etc are computed in that space. This assumption is necessarily valid, but we keep this for compatibility reasons.

In the μ^/σ space, the test statistic (i.e. μ^/σ) is normally distributed with unit variance and its mean at the μ, where μ is the true poi value of the hypothesis.

__init__(shift, cutoff=-inf)[source]#

Asymptotic test statistic distribution.

Parameters:

shift (float) – The displacement of the test statistic distribution.

Returns:

The asymptotic distribution of test statistic.

Return type:

AsymptoticTestStatDistribution

Methods

cdf(value)[source]#

Compute the value of the cumulative distribution function for a given value of the test statistic.

Example

>>> import pyhf
>>> pyhf.set_backend("numpy")
>>> bkg_dist = pyhf.infer.calculators.AsymptoticTestStatDistribution(0.0)
>>> bkg_dist.cdf(0.0)
0.5
Parameters:

value (float) – The test statistic value.

Returns:

The integrated probability to observe a test statistic less than or equal to the observed value.

Return type:

Float

expected_value(nsigma)[source]#

Return the expected value of the test statistic.

Example

>>> import pyhf
>>> pyhf.set_backend("numpy")
>>> bkg_dist = pyhf.infer.calculators.AsymptoticTestStatDistribution(0.0)
>>> n_sigma = pyhf.tensorlib.astensor([-2, -1, 0, 1, 2])
>>> bkg_dist.expected_value(n_sigma)
array([-2., -1.,  0.,  1.,  2.])
Parameters:

nsigma (int or tensor) – The number of standard deviations.

Returns:

The expected value of the test statistic.

Return type:

Float

pvalue(value)[source]#

The p-value for a given value of the test statistic corresponding to signal strength μ and Asimov strength μ as defined in Equations (59) and (57) of [1007.1727]

pμ=1F(qμ|μ)=1Φ(qμ(μμ)σ)

with Equation (29)

(μμ)σ=Λ=qμ,A

given the observed test statistics qμ and qμ,A.

Example

>>> import pyhf
>>> pyhf.set_backend("numpy")
>>> bkg_dist = pyhf.infer.calculators.AsymptoticTestStatDistribution(0.0)
>>> bkg_dist.pvalue(0.0)
array(0.5)
Parameters:

value (float) – The test statistic value.

Returns:

The integrated probability to observe a value at least as large as the observed one.

Return type:

Tensor