pyhf.infer.intervals.upper_limits.upper_limit#
- pyhf.infer.intervals.upper_limits.upper_limit(data, model, scan=None, level=0.05, return_results=False, **hypotest_kwargs)[source]#
Calculate an upper limit interval
(0, poi_up)for a single Parameter of Interest (POI) using root-finding or a linear scan through POI-space.Example
>>> import numpy as np >>> 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) >>> scan = np.linspace(0, 5, 21) >>> obs_limit, exp_limits, (scan, results) = pyhf.infer.intervals.upper_limits.upper_limit( ... data, model, scan, return_results=True ... ) >>> np.isclose(obs_limit, 1.01764089) np.True_ >>> np.isclose(exp_limits, [0.59576921, 0.76169166, 1.08504773, 1.50170482, 2.06654952]) array([ True, True, True, True, True])
- Parameters:
data (
tensor) – The observed data.model (Model) – The statistical model adhering to the schema
model.json.scan (
iterableorNone) – Iterable of POI values orNoneto usetoms748_scan.level (
float) – The threshold value to evaluate the interpolated results at.return_results (
bool) – Whether to return the per-point results.
- Returns:
Tensor: The observed upper limit on the POI.
Tensor: The expected upper limits on the POI.
Tuple of Tensors: The given
scanalong with thehypotestresults at each test POI. Only returned whenreturn_resultsisTrue.
- Return type:
Tuple of Tensors
Added in version 0.7.0.