Skip to content

Commit 097c4bf

Browse files
lukasheinrichmatthewfeickert
authored andcommitted
docs: Add docstrings for src/pyhf/infer (#698)
* Add pydocstyle compliant docstrings to the infer module
1 parent 1867bac commit 097c4bf

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/pyhf/infer/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Inference for Statistical Models."""
2+
13
from .test_statistics import qmu
24
from .utils import (
35
generate_asimov_data,
@@ -11,7 +13,7 @@ def hypotest(
1113
poi_test, data, pdf, init_pars=None, par_bounds=None, qtilde=False, **kwargs
1214
):
1315
r"""
14-
Computes :math:`p`-values and test statistics for a single value of the parameter of interest
16+
Compute :math:`p`-values and test statistics for a single value of the parameter of interest.
1517
1618
Args:
1719
poi_test (Number or Tensor): The value of the parameter of interest (POI)
@@ -75,7 +77,6 @@ def hypotest(
7577
- :math:`\left[q_{\mu}, q_{\mu,A}\right]`: The test statistics for the observed and Asimov datasets respectively. Only returned when ``return_test_statistics`` is ``True``.
7678
7779
"""
78-
7980
init_pars = init_pars or pdf.config.suggested_init()
8081
par_bounds = par_bounds or pdf.config.suggested_bounds()
8182
tensorlib, _ = get_backend()

src/pyhf/infer/utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Utility Functions for model inference."""
12
from .. import get_backend
23

34

@@ -15,6 +16,8 @@ def generate_asimov_data(asimov_mu, data, pdf, init_pars, par_bounds):
1516

1617
def pvals_from_teststat(sqrtqmu_v, sqrtqmuA_v, qtilde=False):
1718
r"""
19+
Compute p-values from test-statistic values.
20+
1821
The :math:`p`-values for signal strength :math:`\mu` and Asimov strength :math:`\mu'` as defined in Equations (59) and (57) of :xref:`arXiv:1007.1727`
1922
2023
.. math::
@@ -36,6 +39,7 @@ def pvals_from_teststat(sqrtqmu_v, sqrtqmuA_v, qtilde=False):
3639
3740
Returns:
3841
Tuple of Floats: The :math:`p`-values for the signal + background, background only, and signal only hypotheses respectivley
42+
3943
"""
4044
tensorlib, _ = get_backend()
4145
if not qtilde: # qmu
@@ -66,16 +70,16 @@ def _false_case():
6670

6771
def pvals_from_teststat_expected(sqrtqmuA_v, nsigma=0):
6872
r"""
69-
Computes the expected :math:`p`-values CLsb, CLb and CLs for data corresponding to a given percentile of the alternate hypothesis.
73+
Compute the expected :math:`p`-values CLsb, CLb and CLs for data corresponding to a given percentile of the alternate hypothesis.
7074
7175
Args:
7276
sqrtqmuA_v (Number or Tensor): The root of the calculated test statistic given the Asimov data, :math:`\sqrt{q_{\mu,A}}`
7377
nsigma (Number or Tensor): The number of standard deviations of variations of the signal strength from the background only hypothesis :math:`\left(\mu=0\right)`
7478
7579
Returns:
7680
Tuple of Floats: The :math:`p`-values for the signal + background, background only, and signal only hypotheses respectivley
77-
"""
7881
82+
"""
7983
# NOTE:
8084
# To compute the expected p-value, one would need to first compute a hypothetical
8185
# observed test-statistic for a dataset whose best-fit value is mu^ = mu'-n*sigma:

0 commit comments

Comments
 (0)