@@ -40,15 +40,16 @@ def generate_asimov_data(
4040 Example:
4141
4242 >>> import pyhf
43+ >>> import numpy as np
4344 >>> pyhf.set_backend("numpy")
4445 >>> model = pyhf.simplemodels.uncorrelated_background(
4546 ... signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
4647 ... )
4748 >>> observations = [51, 48]
4849 >>> data = observations + model.config.auxdata
4950 >>> mu_test = 1.0
50- >>> pyhf.infer.calculators.generate_asimov_data(mu_test, data, model, None, None, None)
51- array( [ 60.61229858, 56.52802479, 270.06832542, 48.31545488])
51+ >>> asimov_data = pyhf.infer.calculators.generate_asimov_data(mu_test, data, model, None, None, None)
52+ >>> np.isclose(asimov_data, [ 60.61229858, 56.52802479, 270.06832542, 48.31545488])
5253 >>> pyhf.infer.calculators.generate_asimov_data(
5354 ... mu_test, data, model, None, None, None, return_fitted_pars=True
5455 ... )
@@ -339,6 +340,7 @@ def teststatistic(self, poi_test):
339340 Example:
340341
341342 >>> import pyhf
343+ >>> import numpy as np
342344 >>> pyhf.set_backend("numpy")
343345 >>> model = pyhf.simplemodels.uncorrelated_background(
344346 ... signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
@@ -347,8 +349,9 @@ def teststatistic(self, poi_test):
347349 >>> data = observations + model.config.auxdata
348350 >>> mu_test = 1.0
349351 >>> asymptotic_calculator = pyhf.infer.calculators.AsymptoticCalculator(data, model, test_stat="qtilde")
350- >>> asymptotic_calculator.teststatistic(mu_test)
351- array(0.14043184)
352+ >>> test_stat = asymptotic_calculator.teststatistic(mu_test)
353+ >>> np.isclose(test_stat, 0.14043184)
354+ True
352355 >>> asymptotic_calculator.fitted_pars
353356 HypoTestFitResults(asimov_pars=array([0. , 1.0030482 , 0.96264534]), free_fit_to_data=array([0. , 1.0030512 , 0.96266961]), free_fit_to_asimov=array([0. , 1.00304893, 0.96263365]), fixed_poi_fit_to_data=array([1. , 0.97224597, 0.87553894]), fixed_poi_fit_to_asimov=array([1. , 0.97276864, 0.87142047]))
354357 >>> asymptotic_calculator.fitted_pars.free_fit_to_asimov # best-fit parameters to Asimov dataset
@@ -478,6 +481,7 @@ def expected_pvalues(self, sig_plus_bkg_distribution, bkg_only_distribution):
478481 Example:
479482
480483 >>> import pyhf
484+ >>> import numpy as np
481485 >>> pyhf.set_backend("numpy")
482486 >>> model = pyhf.simplemodels.uncorrelated_background(
483487 ... signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
@@ -491,8 +495,8 @@ def expected_pvalues(self, sig_plus_bkg_distribution, bkg_only_distribution):
491495 >>> _ = asymptotic_calculator.teststatistic(mu_test)
492496 >>> sig_plus_bkg_dist, bkg_dist = asymptotic_calculator.distributions(mu_test)
493497 >>> CLsb_exp_band, CLb_exp_band, CLs_exp_band = asymptotic_calculator.expected_pvalues(sig_plus_bkg_dist, bkg_dist)
494- >>> CLs_exp_band
495- [array(0.00260626), array(0.01382005), array(0.06445321), array(0.23525644), array(0.57303621)]
498+ >>> np.isclose( CLs_exp_band, [0.00260626, 0.01382005, 0.06445321, 0.23525644, 0.57303621])
499+ True
496500
497501 Args:
498502 sig_plus_bkg_distribution (~pyhf.infer.calculators.AsymptoticTestStatDistribution):
@@ -611,6 +615,7 @@ def expected_value(self, nsigma):
611615 Examples:
612616
613617 >>> import pyhf
618+ >>> import numpy as np
614619 >>> import numpy.random as random
615620 >>> random.seed(0)
616621 >>> pyhf.set_backend("numpy")
@@ -646,9 +651,9 @@ def expected_value(self, nsigma):
646651 ... )
647652 ... )
648653 >>> n_sigma = pyhf.tensorlib.astensor([-2, -1, 0, 1, 2])
649- >>> dist.expected_value(n_sigma)
650- array( [0.00000000e+00, 0.00000000e+00, 5.53671231e-04, 8.29987137e-01,
651- 2.99592664e+00])
654+ >>> exp_values = dist.expected_value(n_sigma)
655+ >>> np.isclose(exp_values, [0.00000000e+00, 0.00000000e+00, 5.53671231e-04, 8.29987137e-01, 2.99592664e+00])
656+ True
652657
653658 Args:
654659 nsigma (:obj:`int` or :obj:`tensor`): The number of standard deviations.
0 commit comments