All problems
Conditional Probability from Joint
Problem
The conditional probability is P(A | B) = P(A and B) / P(B), with P(B) > 0.
Given the joint probability and P(B), return the conditional probability.
Hint
Restrict the sample space to B and renormalize.
Test cases
case 1
in: [0.1,0.5]
expected: 0.2
case 2
in: [0,0.25]
expected: 0
case 3
in: [0.3,0.3]
expected: 1
Starter codePython
def conditional_probability_from_joint(joint, p_b):
# Your code here
pass3 test cases · run your code against them in the editor