All problems
Independence Check
Problem
Return True when two events are independent, i.e. when |P(A and B) - P(A) * P(B)| < 1e-9.
Inputs are p_a, p_b, and the joint probability p_ab.
Hint
Compare the joint probability against the product of the marginals.
Test cases
case 1
in: [0.5,0.4,0.2]
expected: true
case 2
in: [0.5,0.4,0.3]
expected: false
case 3
in: [0,0.5,0]
expected: true
case 4
in: [1,1,1]
expected: true
Starter codePython
def independence_check(p_a, p_b, p_ab):
# Your code here
pass4 test cases · run your code against them in the editor