pyhf.infer.test_statistics.qmu_tilde#

pyhf.infer.test_statistics.qmu_tilde(mu, data, pdf, init_pars, par_bounds, fixed_params, return_fitted_pars=False)[source]#

The “alternative” test statistic, q~μ, for establishing an upper limit on the strength parameter, μ, for models with bounded POI, as defined in Equation (16) in [1007.1727]

q~μ={2lnλ~(μ),μ^μ,0,μ^>μ

where λ~(μ) is the constrained profile likelihood ratio as defined in Equation (10)

λ~(μ)={L(μ,θ^^(μ))L(μ^,θ^^(0)),μ^<0,L(μ,θ^^(μ))L(μ^,θ^),μ^0.

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)
>>> test_mu = 1.0
>>> init_pars = model.config.suggested_init()
>>> par_bounds = model.config.suggested_bounds()
>>> fixed_params = model.config.suggested_fixed()
>>> pyhf.infer.test_statistics.qmu_tilde(
...     test_mu, data, model, init_pars, par_bounds, fixed_params
... )
array(3.93824492)
>>> pyhf.infer.test_statistics.qmu_tilde(
...     test_mu, data, model, init_pars, par_bounds, fixed_params, return_fitted_pars=True
... )
(array(3.93824492), (array([1.        , 0.97224597, 0.87553894]), array([0.        , 1.0030512 , 0.96266961])))
Parameters:
  • mu (Number or Tensor) – The signal strength parameter

  • data (tensor) – The data to be considered

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

  • init_pars (list of float) – The starting values of the model parameters for minimization.

  • par_bounds (list of list/tuple) – The extrema of values the model parameters are allowed to reach in the fit. The shape should be (n, 2) for n model parameters.

  • fixed_params (tuple or list of bool) – The flag to set a parameter constant to its starting value during minimization.

  • return_fitted_pars (bool) – Return the best-fit parameter tensors the fixed-POI and unconstrained fits have converged on (i.e. μ,θ^^ and μ^,θ^)

Returns:

  • The calculated test statistic, q~μ

  • The parameter tensors corresponding to the constrained best fit, μ,θ^^, and the unconstrained best fit, μ^,θ^. Only returned if return_fitted_pars is True.

Return type:

Tuple of a Float and a Tuple of Tensors