Computing the expectation of the number of balls in a box 
  
*
  
*There are $r$ boxes and $n$ balls.
  
*Each ball is placed in a box with equal probability, independently of the other balls.
  
*For each $1 \leq i\leq r$, let $X_{i}$ be the number of balls in box $i$.
  
*Compute $\mathbb{E}\left[X_{i}\right],\ \mathbb{E}\left[X_{i}X_{j}\right]$.
  

I am preparing for an exam, and I have no idea how to approach this problem. Can someone push me in the right direction?
Symmetry reasoning makes it clear that $\mathbb{E}\left[X_{i}\right]$ doesn't depend on $i$. Likewise, $\mathbb{E}\left[X_{i}X_{j}\right]$ doesn't depend on the concrete values of $i$ and $j$ but only (if at all) on whether $i=j$ or $i\neq j$. But this doesn't actually compute these expectations.
 A: For the first part, you can use linearity of expectation to compute $\mathbb{E}[X_i]$. 
Specifically, you know that for a fixed box, the probability of putting a ball in it
is $\frac{1}{r}$. Let
$$
Y_k^{(i)} = \begin{cases}
   1 &, \text{ if ball $k$ was placed in box $i$} \\
   0 &, \text{ otherwise}
\end{cases},
$$
which satisfies $\mathbb{E}[Y_k^{(i)}] = \mathbb{P}(Y_k^{(i)} = 1) = \frac{1}{r}.$
Then you can write
$$
X_i = \sum_{j=1}^n Y_j^{(i)} \Rightarrow \mathbb{E}X_i = \sum_{j=1}^n \frac{1}{r} = \frac{n}{r}.
$$

For the second part, you can proceed similarly: $X_i = \sum_{k=1}^n Y_k^{(i)}$ and $X_j = \sum_{\ell=1}^n Y_{\ell}^{(j)}$, so:
$$
X_i X_j = \sum_{k=1}^n \sum_{\ell=1}^n Y_k^{(i)} Y_{\ell}^{(j)} \implies
\mathbb{E}(X_i X_j) = \sum_{k=1}^n \sum_{\ell=1}^n \mathbb{E}(Y_k^{(i)} Y_{\ell}^{(j)}).
$$
We will first treat the case where $i \ne j$.  Then, for each term in the sum such that $k = \ell$, we must have $Y_k^{(i)} Y_{\ell}^{(j)} = Y_k^{(i)} Y_k^{(j)} = 0$ since it impossible for ball $k$ to be placed both in box $i$ and in box $j$.  On the other hand, if $k \ne \ell$, then the events corresponding to $Y_k^{(i)}$ and $Y_{\ell}^{(j)}$ are independent since the placement of balls $k$ and $\ell$ are independent, which implies that $Y_k^{(i)}$ and $Y_{\ell}^{(j)}$ are independent random variables.  Therefore, in this case,
$$\mathbb{E}(Y_k^{(i)} Y_{\ell}^{(j)}) = \mathbb{E}(Y_k^{(i)}) \mathbb{E}(Y_{\ell}^{(j)}) = \frac{1}{r} \cdot \frac{1}{r}.$$
In summary, if $i \ne j$, then
$$\mathbb{E}(X_i X_j) = \sum_{k=1}^n \sum_{\ell=1}^n \delta_{k \ne \ell} \cdot \frac{1}{r^2} = \frac{n(n-1)}{r^2}$$
where $\delta_{k \ne \ell}$ represents the indicator value which is 1 when $k \ne \ell$ and 0 when $k = \ell$.
For the case $i = j$, I will leave the similar computation of $\mathbb{E}(X_i^2)$ to you, with just the hint that the difference is in the expected value of $\mathbb{E}(Y_k^{(i)} Y_{\ell}^{(j)})$ for the case $k = \ell$.
A: Since there are $r$ boxes and $n$ balls, and each ball is placed in a box with equal probability, we have:
$$ \mathbb{E}[X_i] = \frac{n}{r} $$
Now, we would like to know what is $\mathbb{E}[X_i X_j] $.
We begin by making the following observation:
$$X_i = n - \sum_{j\neq i}X_j $$
Which gives us:
$$ X_i\sum_{j\neq i}X_j = nX_i - X_i^2$$
Now, fix $i$ (we can do this because of the symmetry in the question), and thus we have:
\begin{align}\mathbb{E}[X_i X_j] &= \frac{1}{r}\Big(\mathbb{E}[X_i \sum_{j\neq i} X_j] + \mathbb{E}[X_i^2]\Big) \\
&= \frac{1}{r} \mathbb{E}[nX_i] \\
&= \frac{n^2}{r^2}
\end{align}
A: Think of placing the ball in box "$i$" as success and not placing it as a failure.
This situation can be represented using the Hypergeometric Distribution.
$$
P(X=k) = \frac{{K \choose k} {N- K\choose n - k}}{{N \choose n}}.
$$
$N$ is the population size (number of boxes $r$)
$K$ is the number of success states in  the population (just $1$ because the success is defined as placing the ball in box "$i$".)
$n$ is the number of draws (the number of balls $n$).
$k$ is the number of observed successes (the number of balls in box "$i$").
The expectation of the Hypergeometric Distribution is $n\frac{K}N$, hence the mean of your variable 
$$E[X_i]=n\frac{1}{r}=\frac{n}{r}$$
