@@ -22,6 +22,7 @@ def hypotest(
22
22
return_mle_pars : bool = False ,
23
23
test_stat : str = "q" ,
24
24
expected_pars : Array | None = None ,
25
+ cls_method : bool = True ,
25
26
) -> tuple [Array , Array ] | Array :
26
27
"""Calculate expected CLs/p-values via hypothesis tests.
27
28
@@ -53,7 +54,9 @@ def hypotest(
53
54
The MLE parameters, if `return_mle_pars` is True.
54
55
"""
55
56
if test_stat == "q" :
56
- return qmu_test (test_poi , data , model , lr , return_mle_pars , expected_pars )
57
+ return qmu_test (
58
+ test_poi , data , model , lr , return_mle_pars , expected_pars , cls_method
59
+ )
57
60
elif test_stat == "q0" :
58
61
logging .info (
59
62
"test_poi automatically set to 0 for q0 test (bkg-only null hypothesis)"
@@ -64,7 +67,7 @@ def hypotest(
64
67
65
68
66
69
@partial (
67
- jit , static_argnames = ["model" , "return_mle_pars" ]
70
+ jit , static_argnames = ["model" , "return_mle_pars" , "cls_method" ]
68
71
) # can remove model eventually
69
72
def qmu_test (
70
73
test_poi : float ,
@@ -73,6 +76,7 @@ def qmu_test(
73
76
lr : float ,
74
77
return_mle_pars : bool = False ,
75
78
expected_pars : Array | None = None ,
79
+ cls_method : bool = True ,
76
80
) -> tuple [Array , Array ] | Array :
77
81
# hard-code 1 as inits for now
78
82
# TODO: need to parse different inits for constrained and global fits
@@ -93,9 +97,12 @@ def qmu_test(
93
97
qmu = jnp .where (poi_hat < test_poi , profile_likelihood , 0.0 )
94
98
95
99
CLsb = 1 - pyhf .tensorlib .normal_cdf (jnp .sqrt (qmu ))
96
- altval = 0.0
97
- CLb = 1 - pyhf .tensorlib .normal_cdf (altval )
98
- CLs = CLsb / CLb
100
+ if cls_method :
101
+ altval = 0.0
102
+ CLb = 1 - pyhf .tensorlib .normal_cdf (altval )
103
+ CLs = CLsb / CLb
104
+ else :
105
+ CLs = CLsb
99
106
return (CLs , mle_pars ) if return_mle_pars else CLs
100
107
101
108
0 commit comments