# Mean and variance of occupancy numbers of $N$ balls randomly distributed in $M$ boxes

Consider $N$ balls randomly distributed in $M$ boxes with $N\gg M$ and probability $p_i$ of each individual ball going into box $i$, where each box can contain any number of balls. Let $X_i$ be the occupancy of box $i$. It is clear that $E(X_i) = N p_i$. I thought it was reasonable to assume that $X_i$ are independent and follow a Poisson distribution, so $\sigma^2(X_i) = E(X_i) = N p_i$. However if I define the new random variable $Y_i = \sum_{j=1}^i X_j$ then $\sigma^2(Y_M) = \sum_{j=1}^M \sigma^2(X_j) = \sum_{j=1}^M E(X_j) = N\sum_{j=1}^M p_j$ which is wrong because $Y_M$ is always exactly equal to $N$ and its variance should be zero. So, what are the correct distributions for $X_i$ and $Y_i$?

If the location of each ball is independent of the other balls then each $X_i$ has a binomial distribution $\operatorname{Bin}\left(N,p_i\right)$ and so mean $Np_i$ and variance $Np_i(1-p_i)$
But $X_i$ is not independent of $X_j$: for example they cannot both take the value $N$ when $i \not = j$
If $\displaystyle Y_i = \sum_{j=1}^i X_j$ and letting $\displaystyle q_i=\sum_{j=1}^i p_j$, then each $Y_i$ has a binomial distribution $\displaystyle \operatorname{Bin}\left(N,q_i\right)$ and so mean $Nq_i$ and variance $Nq_i(1-q_i)$
In particular $\displaystyle q_M^{\,} = \sum_{j=1}^M p_j = 1$ so $Y_i$ has mean $N\times 1 =N$ and variance $N\times 1 \times 0=0$ as expected
• Thank you Henry, I actually was searching for the distribution of $Y_i$ but now I'm curious about the distribution of $X_i$ too, is it harder to find? – Manuel Aug 26 '17 at 23:52
• @Manuel: My answer says that each $X_i$ and $Y_i$ is binomially distributed – Henry Aug 27 '17 at 10:12
• Right, I was confused about the independence of the location of balls. One more thing, what would be the covariance between $Y_i$ and $Y_j$? – Manuel Aug 27 '17 at 20:55
• Assuming $i \le j$, it would be $Nq_i(1-q_j)$ – Henry Aug 27 '17 at 21:11