@@ -241,3 +241,47 @@ def test_clopper_pearson_interval():
241241 threshold = 1e-6
242242 assert (all ((interval [1 , :] / ref_hi ) - 1 < threshold ))
243243 assert (all ((interval [0 , :] / ref_lo ) - 1 < threshold ))
244+
245+ def test_normal_interval ():
246+ from coffea .hist .plot import normal_interval
247+
248+ # Reference weighted efficiency and error from ROOTs TEfficiency
249+
250+ denom = np .array ([ 89.01457591590004 , 2177.066076428943 , 6122.5256890981855 ,
251+ 0. , 100.27757990710668 ])
252+ num = np .array ([ 75.14287743709515 , 2177.066076428943 , 5193.454723043864 ,
253+ 0. , 84.97723540536361 ])
254+ denom_sumw2 = np .array ([ 94.37919737476827 , 10000. , 6463.46795877633 ,
255+ 0. , 105.90898005417333 ])
256+ num_sumw2 = np .array ([ 67.2202147680005 , 10000. , 4647.983931785646 ,
257+ 0. , 76.01275761253757 ])
258+ ref_hi = np .array ([0.0514643476600107 , 0. , 0.0061403263960343 ,
259+ np .nan , 0.0480731185500146 ])
260+ ref_lo = np .array ([0.0514643476600107 , 0. , 0.0061403263960343 ,
261+ np .nan , 0.0480731185500146 ])
262+
263+ interval = normal_interval (num , denom , num_sumw2 , denom_sumw2 )
264+ threshold = 1e-6
265+
266+ lo , hi = interval
267+
268+ assert len (ref_hi ) == len (hi )
269+ assert len (ref_lo ) == len (lo )
270+
271+ for i in range (len (ref_hi )):
272+ if np .isnan (ref_hi [i ]):
273+ assert np .isnan (ref_hi [i ])
274+ elif ref_hi [i ] == 0.0 :
275+ assert hi [i ] == 0.0
276+ else :
277+ assert np .abs (hi [i ] / ref_hi [i ] - 1 ) < threshold
278+
279+ if np .isnan (ref_lo [i ]):
280+ assert np .isnan (ref_lo [i ])
281+ elif ref_lo [i ] == 0.0 :
282+ assert lo [i ] == 0.0
283+ else :
284+ assert np .abs (lo [i ] / ref_lo [i ] - 1 ) < threshold
285+
286+
287+
0 commit comments