pyhf.infer.hypotest#
- pyhf.infer.hypotest(poi_test, data, pdf, init_pars=None, par_bounds=None, fixed_params=None, calctype='asymptotics', return_tail_probs=False, return_expected=False, return_expected_set=False, return_calculator=False, **kwargs)[source]#
Compute
-values and test statistics for a single value of the parameter of interest.See
AsymptoticCalculator
andToyCalculator
on additional keyword arguments to be specified.Example
>>> import pyhf >>> pyhf.set_backend("numpy") >>> model = pyhf.simplemodels.uncorrelated_background( ... signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0] ... ) >>> observations = [51, 48] >>> data = pyhf.tensorlib.astensor(observations + model.config.auxdata) >>> mu_test = 1.0 >>> CLs_obs, CLs_exp_band = pyhf.infer.hypotest( ... mu_test, data, model, return_expected_set=True, test_stat="qtilde" ... ) >>> CLs_obs array(0.05251497) >>> CLs_exp_band [array(0.00260626), array(0.01382005), array(0.06445321), array(0.23525644), array(0.57303621)]
- Parameters:
poi_test (Number or Tensor) – The value of the parameter of interest (POI)
data (Number or Tensor) – The data considered
pdf (Model) – The statistical model adhering to the schema
model.json
init_pars (
tensor
offloat
) – The starting values of the model parameters for minimization.par_bounds (
tensor
) – The extrema of values the model parameters are allowed to reach in the fit. The shape should be(n, 2)
forn
model parameters.fixed_params (
tuple
orlist
ofbool
) – The flag to set a parameter constant to its starting value during minimization.calctype (
str
) – The calculator to create. Choose either ‘asymptotics’ (default) or ‘toybased’.return_tail_probs (
bool
) – Bool for returning andreturn_expected (
bool
) – Bool for returningreturn_expected_set (
bool
) – Bool for returning the — the “Brazil band”return_calculator (
bool
) – Bool for returning calculator.
- Returns:
Tuple of Floats and lists of Floats and a
AsymptoticCalculator
orToyCalculator
instance: : The modified -value compared to the given threshold , typically taken to be , defined in [1007.1727] as
to protect against excluding signal models in which there is little sensitivity. In the case that
the given signal model is excluded. : The signal + background model hypothesis -value
and 1 minus the background only model hypothesis
-valuefor signal strength
and model hypothesis signal strength , where the cumulative density functions are given by Equations (57) and (65) of [1007.1727] for upper-limit-like test statistic . Only returned whenreturn_tail_probs
isTrue
.Note
The definitions of the
and used are based on profile likelihood ratio test statistics. This procedure is common in the LHC-era, but differs from procedures used in the LEP and Tevatron eras, as briefly discussed in 3.8 of [1007.1727]. : The expected value corresponding to the test statistic under the background only hypothesis . Only returned whenreturn_expected
isTrue
. band: The set of expected values corresponding to the median significance of variations of the signal strength from the background only hypothesis at . That is, the -values that satisfy Equation (89) of [1007.1727]
for
and . These values define the boundaries of an uncertainty band sometimes referred to as the “Brazil band”. Only returned whenreturn_expected_set
isTrue
.a calculator: The calculator instance used in the computation of the
-values. Either an instance ofAsymptoticCalculator
orToyCalculator
, depending on the value ofcalctype
. Only returned whenreturn_calculator
isTrue
.