Let $\Omega$ be the set of all permutations on the set {1,2,...,n}, equipped with the uniform measure. For a permutation $\sigma \in \Omega$ let $X(\sigma)$ denote the number of fixed points by $\sigma$, i.e. $$X(\sigma)=card\{1 \leq j \leq n: \sigma(j)=j \}$$.
I computed that $\mathbb{E}[X]=1$ and I am now trying to compute $ \mathbb{E}[X^2] $. Could anyone help me?
Thanks in advance.
For $j=1,\dots,n$ define $U_{j}\left(\sigma\right)=1$ if $\sigma\left(j\right)=j$ and $U_{j}\left(\sigma\right)=0$ otherwise.
Then $X=\sum_{j=1}^{n}U_{j}$ and consequently $X^{2}=\sum_{i=1}^{n}\sum_{j=1}^{n}U_{i}U_{j}$.
Here $U_{j}^{2}=U_{j}$ and because of symmetry:
$$\mathbb{E}X^{2}=n\mathbb{E}U_{1}+n\left(n-1\right)\mathbb{E}U_{1}U_{2}$$
It remains to find $\mathbb EU_1=P(U_1=1)$ and $\mathbb EU_1U_2=P(U_1=U_2=1)$. Can you do that?