A question about calculating expectation value and variance 
This is a problem on probability theory that I'm stuck at. I know the probability of having exactly k fixed points where k = 1, ..., n 
It is given as below
However, adding up the probabilities and calculating the expectation value and variance seems very "dirty". I can't simplify the expectation value and variance to something more "neat". Could anyone help me how to correctly calculate those values?
 A: Define the random variables $X_1,\dots,X_n$ by $X_i=1$ if the permutation has $i$ as a fixed point, and by $X_i=0$ otherwise. Then the number of fixed points, which I will call $Y$, is given by $Y=X_1+\cdots+X_n$.
By the linearity of expectation, we have $E(Y)=E(X_1)+\cdots+E(X_n)$. But $\Pr(X_i)=1)=\frac{1}{n}$, so $E(X_i)=\frac{1}{n}$, and thus $E(Y)=n\cdot \frac{1}{n}=1$.
Now we calculate the variance of $Y$. It is enough to find $E(Y^2)$, for the variance of $Y$ is $E(Y^2)-1^2$.
To find the expectation of $Y^2$, expand $(X_1+\cdots +X_n)^2$and again use the linearity of expectation.
When we expand, we get $X_1^2+\cdots+X_n^2$ plus the sum of the cross terms $X_iX_j$ where $i\ne j$. There are $n(n-1)$ such terms. 
The expectation of $X_i^2$ is $\frac{1}{n}$ because $X_i^2=X_i$.
To find $E(X_iX_j)$ where $i\ne j$, note that $X_iX_j=1$ precisely if $i$ and $j$ are fixed points. The probability $i$ and $j$ are fixed points is $\frac{1}{n}\cdot\frac{1}{n-1}$. 
Now you can put the pieces together. The variance turns out to be very simple. 
Remark: We could find the distribution of $Y$, and then use the usual expressions to try to calculate $E(Y)$ and $E(Y^2)$. If we use that approach, the calculation of $E(Y)$ in simple form is not too bad, but the calculation of $E(Y^2)$ is somewhat unpleasant. The method of indicator random variables that we used bypasses all of that.
