All problems
Bayes Two Hypotheses
Problem
Two-hypothesis Bayes update given a test result.
Return [P(H | positive), P(H | negative)] where sensitivity = P(+ | H), specificity = P(- | not H) and prior = P(H). Use total probability to compute P(+) and P(-), and return 0.0 for any zero denominator.
Hint
P(+) = sensitivity * prior + (1 - specificity) * (1 - prior).
Test cases
case 1
in: [0.01,0.9,0.95]
expected: [0.15384615384615374,0.0010621348911311734]
case 2
in: [0.5,1,1]
expected: [1,0]
case 3
in: [0,0.9,0.9]
expected: [0,0]
case 4
in: [1,0.8,0.7]
expected: [1,1]
Starter codePython
def bayes_two_hypotheses(prior, sensitivity, specificity):
# Your code here
pass4 test cases · run your code against them in the editor