All problems
Inclusion Exclusion Union Probability
Problem
For three events, P(A or B or C) = (sum of single probabilities) - (sum of pairwise intersection probabilities) + P(A and B and C).
Given the three single probabilities, the three pairwise probabilities, and the triple probability, return the union probability.
Hint
Alternate signs starting with plus.
Test cases
case 1
in: [[0.5,0.4,0.3],[0.2,0.15,0.1],0.05]
expected: 0.8
case 2
in: [[0.1,0.1,0.1],[0,0,0],0]
expected: 0.30000000000000004
case 3
in: [[0.9,0.8,0.7],[0.7,0.6,0.6],0.5]
expected: 1
Starter codePython
def inclusion_exclusion_union_probability(singles, pairs, triple):
# Your code here
pass3 test cases · run your code against them in the editor