31. Inclusion-Exclusion for Three Events

Hard

The two-event addition rule generalises, but the signs alternate: add the singles, subtract every pair, then add the triple back because it was removed one time too many.

P(ABC)=P(A)+P(B)+P(C)P(AB)P(AC)P(BC)+P(ABC)P(A \cup B \cup C) = P(A)+P(B)+P(C) - P(A\cap B)-P(A\cap C)-P(B\cap C) + P(A\cap B\cap C)

Return P(ABC)P(A \cup B \cup C).

solve(0.5, 0.5, 1/3, 0.25, 1/6, 1/6, 1/6)  ->  0.9166666666666666

Sketch a three-circle diagram if the signs feel arbitrary: the centre region sits inside all three singles and all three pairs.

Sign in to write and run your own code.

Implement solve(...)