pyhf.infer.test_statistics.tmu#
- pyhf.infer.test_statistics.tmu(mu, data, pdf, init_pars, par_bounds, fixed_params, return_fitted_pars=False)[source]#
The test statistic, \(t_{\mu}\), for establishing a two-sided interval on the strength parameter, \(\mu\), as defined in Equation (8) in [1007.1727]
\[t_{\mu} = -2\ln\lambda\left(\mu\right)\]where \(\lambda\left(\mu\right)\) is the profile likelihood ratio as defined in Equation (7)
\[\lambda\left(\mu\right) = \frac{L\left(\mu, \hat{\hat{\boldsymbol{\theta}}}\right)}{L\left(\hat{\mu}, \hat{\boldsymbol{\theta}}\right)}\,.\]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() >>> par_bounds[model.config.poi_index] = [-10.0, 10.0] >>> fixed_params = model.config.suggested_fixed() >>> pyhf.infer.test_statistics.tmu( ... test_mu, data, model, init_pars, par_bounds, fixed_params ... ) array(3.9549891) >>> pyhf.infer.test_statistics.tmu( ... test_mu, data, model, init_pars, par_bounds, fixed_params, return_fitted_pars=True ... ) (array(3.9549891), (array([1. , 0.97224597, 0.87553894]), array([-0.06679525, 1.00555369, 0.96930896])))
- 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
offloat
) – The starting values of the model parameters for minimization.par_bounds (
list
oflist
/tuple
) – 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.return_fitted_pars (
bool
) – Return the best-fit parameter tensors the fixed-POI and unconstrained fits have converged on (i.e. \(\mu, \hat{\hat{\theta}}\) and \(\hat{\mu}, \hat{\theta}\))
- Returns:
The calculated test statistic, \(t_{\mu}\)
The parameter tensors corresponding to the constrained best fit, \(\mu, \hat{\hat{\theta}}\), and the unconstrained best fit, \(\hat{\mu}, \hat{\theta}\). Only returned if
return_fitted_pars
isTrue
.
- Return type:
Tuple of a Float and a Tuple of Tensors