All problems
Post-Test Probability
Problem
Return the post-test probability after a positive test: multiply the pre-test odds prevalence/(1-prevalence) by the positive likelihood ratio and convert the result back to a probability. Return 0.0 when prevalence is outside (0, 1) or specificity >= 1.
Hint
Odds in, likelihood ratio scaling, probability out.
Test cases
case 1
in: [0.1,0.9,0.8]
expected: 0.3333333333333334
case 2
in: [0.5,0.5,0.5]
expected: 0.5
case 3
in: [0.01,1,0.95]
expected: 0.1680672268907562
case 4
in: [0.2,0.8,1]
expected: 0
case 5
in: [0,0.9,0.8]
expected: 0
Starter codePython
def post_test_probability(prevalence, sensitivity, specificity):
# Your code here
pass5 test cases · run your code against them in the editor