Finding the expectation value of a random variable counting the occurrences of certain events Let there be $M$ (distinguishable) boxes and $N$ balls, which we uniformly distribute among the boxes. For $k \leq N$, let $g_k: \Omega \rightarrow \mathbb{Z}$ be the function counting the number of boxes yielding exactly $k$ balls. Note that I am a bit reluctant to specify $\Omega$ (Distinguish the boxes or not?) as it seems key to me to find a clever way to sort the events in it. 
What would be the expectation value of $g_k$ then?
 A: In real life probability the balls and boxes will be distinguishable to get equally probable events (though perhaps not in sub-atomic physics). 
You can calculate $E[g_k]$ using the binomial distribution and linearity of expectation: take the probability of the first box having $k$ out of $N$ balls and multiply by the number of boxes.
So $\displaystyle E[g_k] = {N \choose k} \frac{(M-1)^{N-k}}{M^{N-1}}.$
A: We assume that for each of the $N$ balls, we choose a box uniformly and independently. For any box $i$, let $X_i=1$ if Box $i$ has exactly $k$ balls, and let $X_i=0$ otherwise. Then the number $Y$ of boxes with exactly $k$ balls is $\sum_1^M X_i$. By the linearity of expectation, we have
$$E(Y)=\sum E(X_i)=ME(X_1).$$
It remains to find $E(X_1)$. Since $X_1$ is a  Bernoulli random variable, $E(X_1)=\Pr(X_1=1)$. But
$$\Pr(X_1=1)=\binom{N}{k}\left(\frac{1}{M}\right)^k\left(\frac{M-1}{M}\right)^{N-k}.$$
Remark: The distribution of $Y$ would be quite unpleasant to get at. The method of Indicator Random Variables bypasses finding the distribution. 
A: Hint:
For every box $i$ let $B_{k,i}$ take value $1$ if it contains $k$
balls and $0$ otherwise. Then $g_{k}=\sum_{i=1}^{M}B_{k,i}$ and
consequently $\mathbb{E}g_{k}=\sum_{i=1}^{M}\mathbb{E}B_{k,i}=Mp_k$
where $p_k$ denotes the probability that a specified box contains $k$
balls.
For finding $p_k$ have a look at the answer of André.
