Skip to content
DeepForgeby svx
All problems
HardStatisticsst-139

NNT Confidence Interval

Problem

Return [NNT, low, high] where NNT = 1/|RD| for the risk difference a/(a+b) - c/(c+d), and the bounds are 1/|CI endpoints| sorted ascending, using the supplied critical value. Return [0.0, 0.0, 0.0] when a group is empty, the risk difference is zero, or the confidence interval contains zero.

Hint

Confidence limits for NNT are reciprocals of the risk-difference limits.

Test cases

case 1
in: [20,80,10,90,1.96]
expected: [10,5.05050505050505,499.99999999999955]
case 2
in: [10,10,10,10,1.96]
expected: [0,0,0]
case 3
in: [30,70,15,85,1.96]
expected: [6.666666666666667,3.789806559425875,27.67454433101525]
case 4
in: [0,10,5,5,2]
expected: [2,1.2251482265544136,5.441518440112253]
case 5
in: [5,0,1,1,1.96]
expected: [0,0,0]
Starter codePython
def nnt_ci(a, b, c, d, z_crit):
    # Your code here
    pass

5 test cases · run your code against them in the editor