Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-345

Independent Event Pair Check

Problem

Two events are independent when P(A and B) equals P(A) P(B); check within a tolerance.

Given the three probabilities and the tolerance, return True when the pair is independent.

Hint

Compare the joint against the product with a strict tolerance.

Test cases

case 1
in: [0.5,0.5,0.25,1e-9]
expected: true
case 2
in: [0.5,0.5,0.3,1e-9]
expected: false
case 3
in: [0.2,0.3,0.06,1e-9]
expected: true
Starter codePython
def independent_event_pair_check(p_a, p_b, p_both, tol):
    # Your code here
    pass

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