pyhf.infer.intervals.upper_limits.linear_grid_scan#

pyhf.infer.intervals.upper_limits.linear_grid_scan(data, model, scan, 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 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
... )
>>> obs_limit
array(1.01764089)
>>> exp_limits
[array(0.59576921), array(0.76169166), array(1.08504773), array(1.50170482), array(2.06654952)]
Parameters:
  • data (tensor) – The observed data.

  • model (Model) – The statistical model adhering to the schema model.json.

  • scan (iterable) – Iterable of POI values.

  • level (float) – The threshold value to evaluate the interpolated results at.

  • return_results (bool) – Whether to return the per-point results.

  • hypotest_kwargs (string) – Kwargs for the calls to hypotest to configure the fits.

Returns:

  • Tensor: The observed upper limit on the POI.

  • Tensor: The expected upper limits on the POI.

  • Tuple of Tensors: The given scan along with the hypotest results at each test POI. Only returned when return_results is True.

Return type:

Tuple of Tensors

Added in version 0.7.0.