pyhf.infer.utils.create_calculator#

pyhf.infer.utils.create_calculator(calctype, *args, **kwargs)[source]#

Creates a calculator object of the specified calctype.

See AsymptoticCalculator and ToyCalculator on additional arguments to be specified.

Example

>>> import pyhf
>>> import numpy.random as random
>>> random.seed(0)
>>> 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 = observations + model.config.auxdata
>>> mu_test = 1.0
>>> toy_calculator = pyhf.infer.utils.create_calculator(
...     "toybased", data, model, ntoys=100, test_stat="qtilde", track_progress=False
... )
>>> qmu_sig, qmu_bkg = toy_calculator.distributions(mu_test)
>>> qmu_sig.pvalue(mu_test), qmu_bkg.pvalue(mu_test)
(array(0.14), array(0.79))
Parameters:
  • calctype (str) – The calculator to create. Choose either

  • 'toybased'. ('asymptotics' or)

Returns:

A calculator.

Return type:

calculator (object)