Mathwords logoMathwords

Occupancy Problem — Definition, Formula & Example

The occupancy problem is the classic question of what happens when you drop balls into bins at random: how many bins end up empty, how many hold two or more balls, or whether every bin gets at least one.

Place nn balls into kk bins, and let NiN_i be the number of balls in bin ii, so that N1+⋯+Nk=nN_1 + \cdots + N_k = n. An occupancy problem asks for the probability distribution of some function of the occupancy vector (N1,…,Nk)(N_1, \dots, N_k), such as the number of empty bins. In the standard model, the balls are distinguishable and each one lands in any bin with probability 1k\tfrac{1}{k}, independently of the others. Then all knk^n assignments are equally likely, and P(N1=n1,…,Nk=nk)=n!n1!⋯nk! k−nP(N_1 = n_1, \dots, N_k = n_k) = \dfrac{n!}{n_1! \cdots n_k!}\,k^{-n}.

Key Formula

P(no bin empty)=1kn∑j=0k(−1)j(kj)(k−j)nP(\text{no bin empty}) = \frac{1}{k^n}\sum_{j=0}^{k} (-1)^j \binom{k}{j} (k-j)^n
Where:
  • nn = Number of balls (distinguishable), each placed at random
  • kk = Number of bins, each equally likely for every ball
  • jj = Number of bins forced to be empty in each inclusion-exclusion term
  • (kj)\binom{k}{j} = Number of ways to choose which jj bins are left empty

Worked Example

Problem: Four shoppers each pick one of 3 open checkout lanes at random, independently. What is the probability that every lane gets at least one shopper?
Step 1: Count all outcomes. Each of the 4 shoppers has 3 lane choices, and every assignment is equally likely.
34=813^4 = 81
Step 2: Use inclusion-exclusion to count the outcomes with no empty lane. First subtract the outcomes that miss at least one lane, which is 3 ways to pick the lane times 242^4 assignments. Subtracting this way removes the outcomes that miss two lanes twice, so add those back once.
34−(31)24+(32)14=81−48+3=363^4 - \binom{3}{1}2^4 + \binom{3}{2}1^4 = 81 - 48 + 3 = 36
Step 3: Divide the favorable outcomes by the total.
P=3681=49≈0.444P = \frac{36}{81} = \frac{4}{9} \approx 0.444
Answer: The probability that all 3 lanes are used is 49≈0.444\tfrac{4}{9} \approx 0.444, a bit less than half.

Why It Matters

Computer scientists use occupancy results to predict collisions in hash tables, where the keys are the balls and the slots are the bins. In statistical physics, the three ways of counting balls in bins match Maxwell-Boltzmann, Bose-Einstein, and Fermi-Dirac statistics for particles in energy states. The birthday problem and the coupon collector problem are both special cases.

Common Mistakes

Mistake: Counting the distinct occupancy patterns and treating them as equally likely. For 4 balls in 3 bins, stars and bars gives (62)=15\binom{6}{2} = 15 patterns, so students write the probability of a pattern as 115\tfrac{1}{15}.
Correction: Shoppers, coins, and other physical objects are distinguishable, so the equally likely outcomes are the 34=813^4 = 81 assignments, not the 15 patterns. The pattern (4, 0, 0) arises from 1 assignment, but (2, 1, 1) arises from 12. Count assignments, or use the multinomial formula.

Related Terms