Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-106

Union Bound

Problem

Boole's inequality bounds the probability of a union by the sum of the individual probabilities:

P(union) <= min(1, sum(probs)).

Return the bound for the given list of probabilities.

Hint

The bound can exceed 1, so cap it.

Test cases

case 1
in: [[0.1,0.2,0.3]]
expected: 0.6
case 2
in: [[0.5,0.5]]
expected: 1
case 3
in: [[0.2,0.2,0.2,0.2,0.2,0.2]]
expected: 1
case 4
in: [[]]
expected: 0
Starter codePython
def union_bound(probs):
    # Your code here
    pass

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