Premium problem31. Inclusion-Exclusion for Three Events

Hard Locked

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(A∪B∪C)=P(A)+P(B)+P(C)−P(A∩B)−P(A∩C)−P(B∩C)+P(A∩B∩C)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(A∪B∪C)P(A \cup B \cup C).

Input

p_a = 0.5
p_b = 0.5
p_c = 0.3333333333333333
p_ab = 0.25
p_ac = 0.16666666666666666
p_bc = 0.16666666666666666
p_abc = 0.16666666666666666

Output

0.9166666666666666

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)