Expected value of $E[X_1^2+\dots X_n^2]$ $n$ randomly throw balls to $n$ urns. Let $X_i$ wil be number of balls in the $i$-th urn. Compute $$E[X_1^2+\dots X_n^2]$$
So I'm trying, but it's tricky for me
$$E[X_1^2+\dots X_n^2] = E[X_1^2]+\dots+E[X_n^2]  = nE[X_i^2] $$
$$E[X_i^2] = \sum_{i=0}^{n} \left(\frac {{n\choose i}(n-i) }{n^n}\right)^2 i$$  
But I don't manage to finish it. Help me, please.
 A: $X_i$ have the same binomial distribution with parameters $p=\frac{1}{n}$ and $n,$ because one ball can drop in to $i-$th urn with probability $\frac{1}{n}$ or other urn with probability $\frac{n-1}{n}.$ Now, You can easy compute $\mathbb{E}X_i^2=\mathbb{D}^2 X_i+(\mathbb{E}X_i)^2=n \frac{1}{n} \frac{n-1}{n}+(n \frac{1}{n})^2=2-\frac{1}{n}.$
$X_i$ are not independent but do not mind. The property $\mathbb{E}(X_1+\ldots+X_n)=\mathbb{E}X_1+\ldots+\mathbb{E}X_n$ is true for any integrable random variables $X_i.$
A: You have $n$ balls in $n$ throws.


*

*If you have $k_1,k_2,\cdots,k_n$ balls in the urns the number of ways of having that configuration is (see note 1):
$${n \choose k_1}{n-k_1 \choose k_2}\cdots {n-k_1-\cdots-k_{n-2} \choose k_{n-1}}{n-k_1-\cdots-k_{n-1} \choose k_n}=\frac{n!}{k_1!k_2!\cdots k_n!}$$ 

*The total number of configurations is $n^n$ (you have $n$ options for each one of the $n$ balls)


Then the probability of having a $k_1,\cdots,k_n$ balls is:
$$\mathbb{P}(X_1=k_1,\cdots,X_n=k_n)=\frac{1}{n^n}\frac{n!}{k_1!k_2!\cdots k_n!}$$
Then:
$$\mathbb{E}(X_1^2+X_2^2+\cdots+X_n^2)=\mathbb{E}\left((X_1+\cdots+X_n)^2-\sum_{i \neq j} X_iX_j\right)$$
$$=n^2-\sum_{i \neq j}\mathbb{E}\left( X_iX_j\right)$$
The cross expectations are (see note 2):
$$\mathbb{E}(X_iX_j)=\sum_{k_1+k_2+...+k_n=n} k_i k_j  \frac{n!}{k_1!k_2!\cdots k_n!}\frac{1}{n^n}=\frac{n-1}{n}$$
How the terms with $i \neq j $ are $n^2-n$:
$$\mathbb{E}(X_1^2+X_2^2+\cdots+X_n^2)=n^2-(n^2-n)\frac{n-1}{n}=2n-1$$

Note 1
We have to choose $k_1$ balls from $n$ balls to be put in the urn $1$
  then you have ${n \choose k_1}$ ways of doing it.
We have to choose $k_2$ balls from $n-k_1$ balls to be put in the urn
  $2$ then you have ${n \choose k_1}$ ways of doing it.
We have to choose $k_n$ balls from $n-k_1-\cdots-k_{n-1}$ balls to be
  put in the urn $n$ then you have ${n-k_1-\cdots-k_{n-1} \choose k_n}$
  ways of doing it.
Then the configuration have a total number of doing it of:
$${n \choose k_1}{n-k_1 \choose k_2}\cdots {n-k_1-\cdots-k_{n-2}\choose k_{n-1}}{n-k_1-\cdots-k_{n-1} \choose k_n}$$
Simplifying the combinatorials numbers you would get
$${n \choose k_1}{n-k_1 \choose k_2}\cdots {n-k_1-\cdots-k_{n-2} \choose k_{n-1}}{n-k_1-\cdots-k_{n-1} \choose k_n}=\frac{n!}{k_1!k_2!\cdots k_n!}$$
Note 2
By the multinomial theorem we know that:
$$(x_1 + x_2  + \cdots + x_n)^n =\sum_{k_1+k_2+\cdots+k_n=n}\frac{n!}{k_1!k_2!\cdots k_n!}x_1^{k_1} x_2^{k_2} \cdots x_n^{k_n}$$
Differentiating with respect to $x_i$ and then respect to $x_j$:
$$n(n-1)(x_1 + x_2  + \cdots + x_n)^{n-2} =\sum_{k_1+k_2+\cdots+k_n=n}k_i k_j\frac{n!}{k_1!k_2!\cdots k_n!}x_1^{k_1} \cdots x_k^{k_i-1}x_j^{k_j-1} \cdots x_n^{k_n}$$
  $$=\frac{1}{x_i}\frac{1}{x_j}\sum_{k_1+k_2+\cdots+k_n=n} k_i k_j\frac{n!}{k_1!k_2!\cdots k_n!}x_1^{k_1} x_2^{k_2} \cdots x_n^{k_n}$$
Finally:
$$n(n-1)(x_1 + x_2  + \cdots + x_n)^{n-2} x_ix_j=\sum_{k_1+k_2+\cdots+k_n=n} k_ik_j \frac{n!}{k_1!k_2!\cdots k_n!}x_1^{k_1} x_2^{k_2} \cdots x_n^{k_n}$$
Then if $x_k=\frac{1}{n} \ \ \forall i=1..n$
$$\frac{n-1}{n}=\frac{1}{n^n}\sum_{k_1+k_2+\cdots+k_n=n}k_ik_j\frac{n!}{k_1!k_2!\cdots k_n!}x_1^{k_1}x_2^{k_2}\cdots x_n^{k_n}$$

