Distributing balls into bins for large numbers: approximating probabilities

40 Views Asked by At

Distributing $n$ balls into $m$ bins with $n > m$, I want to calculate the probability that at least one box will be empty. If I'm not mistaken, that should be

$$p_{m} = 1 - \frac{m! S_n^{(m)}}{m^n}$$

My challenge here is, that I need to compute these probabilities in my software with $n \in [100, 5000]$. More specifically, $n$ is an input parameter from the user, and I perform a binary search to determine the smallest $m$ such that $p_m >= P$ for a threshold $P$ also given by the user. Currently, I simulate it, which is neither really efficient, nor really pretty. I was wondering whether I could also compute (or approximate) $p_m$, without calculating it naively using the formula above. I know about the approximation of factorials (Stirling's approximation), but I didn't have much luck finding approximations for Stirling numbers, but maybe there are already approximations out there for "distributing balls into bins" problems?