How this calculation works
Find the exact distribution of the number of occupied boxes when labeled balls are independently assigned to equally likely labeled boxes. Counts are accumulated as integers before probabilities are formed, avoiding simulation noise. The calculator reports an occupancy distribution and its expectation, including the zero-ball case. It concerns how many boxes receive at least one ball, not the load of one particular box.
A(n+1,k)=k A(n,k)+(m−k+1) A(n,k−1); P(K=k)=A(n,k)/m^n.A worked example
Three labeled balls choose independently between two boxes, giving eight equally likely assignments. Two assignments occupy one box and six occupy both. The expected number of occupied boxes is (2×1+6×2)/8=1.75.
Good to know
0–100 labeled balls and 1–100 labeled boxes, uniform independent placement. Integer counts are exact; probabilities are floating-point ratios. No capacities, unequal box probabilities or guaranteed worst-case occupancy.
The experiment being counted
Each ball chooses one of the boxes independently and uniformly, so with n balls and m boxes there are m raised to n equally likely assignments. Ball labels matter even though the final statistic ignores which ball went where.
This differs from choosing an unordered composition of n or treating all occupancy patterns as equally likely. A pattern with many distinguishable assignments receives more probability than one represented by only a few assignments.
A probability distribution under random allocations, rather than a deterministic worst-case pigeonhole guarantee. The Gaussian discriminant classification calculator from labeled observations offers a complementary calculation under its own stated assumptions.
An exact counting recurrence
After some balls have been placed, suppose k boxes are occupied. The next ball has k choices that preserve k occupied boxes and m minus k choices that create one additional occupied box.
Propagating integer counts through those two transitions produces the full distribution. The sum of final counts is checked against the total assignment count. This certificate verifies conservation of possibilities, though it does not change the uniform independent-allocation assumption.
Worked example and mathematical rule
Three labeled balls choose independently between two boxes, giving eight equally likely assignments. Two assignments occupy one box and six occupy both. The expected number of occupied boxes is (2×1+6×2)/8=1.75.
A(n+1,k)=k A(n,k)+(m−k+1) A(n,k−1); P(K=k)=A(n,k)/m^n.
Why the expectation has a short formula
For each box, define an indicator that it is occupied. A specified box stays empty only when every ball chooses one of the other boxes, with probability one minus one over m raised to n.
Summing the occupied probabilities over m boxes gives the displayed expectation. Independence between occupancy indicators is not needed for this expectation argument; in fact, those indicators are dependent. The expectation can be fractional because it averages integer occupied-box counts across many assignments.
Impossible outcomes and boundary cases
With no balls, exactly zero boxes are occupied. With at least one ball, zero occupied boxes is impossible, and the maximum possible occupancy is the smaller of the ball and box counts.
One box is occupied with certainty when there is only one available box and at least one ball. Zero-probability rows outside the feasible range are meaningful, not numerical failures. They make it easier to distinguish the possible support from the range of indices used in the recurrence.
Connections to collisions and coverage
The chance that every ball lands in a different box is the probability that occupied boxes equals the ball count, provided enough boxes exist. The chance every box is used is the mass at m.
Expected collisions can be described as n minus the expected number of occupied boxes when each additional ball in an already occupied box counts as a collision. That definition differs from counting colliding pairs, whose expectation follows a different formula.
When equal allocation is inappropriate
Unequal box probabilities, capacity limits or dependence between ball placements require a different model. Examples include nonuniform hash functions, preferential attachment and sampling without replacement.
Large integer counts are retained exactly internally, but probability display uses floating-point numbers and can underflow for extremely rare events. Report the event definition and model alongside a tiny probability. Do not infer that an event is mathematically impossible solely because its rounded display is zero.
A few questions, answered
Are all occupancy patterns equally likely?
No. The equally likely objects are labeled ball-to-box assignments.
Can the expected occupancy be noninteger?
Yes. It is a probability-weighted average of integer outcomes.
Is this the probability of at least one collision?
That can be read as one minus the probability that all balls occupy distinct boxes.
Can boxes have different probabilities?
This implementation assumes every ball chooses every box with equal probability.