Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-154

Expected Empty Bins

Problem

Expected number of empty bins after balls are thrown independently and uniformly into bins:

E[empty] = bins * (1 - 1 / bins)^balls.

Use linearity of expectation over bins. Return 0.0 for bins <= 0 or balls < 0.

Hint

Each fixed bin stays empty with probability (1 - 1 / bins)^balls.

Test cases

case 1
in: [10,10]
expected: 3.486784401000001
case 2
in: [0,5]
expected: 5
case 3
in: [5,5]
expected: 1.6384000000000003
case 4
in: [3,0]
expected: 0
Starter codePython
def expected_empty_bins(balls, bins):
    # Your code here
    pass

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