I was studying permutation groups and I founs this question-
Let $S_n$ be the group of all permutations of the set $X=\{1,2,\dots,n\}$. Given a permutation $\sigma\in S_n$, let $f(\sigma)$ denote the number of fixed points of $\sigma$.
a. Show that the average number of fixed points is $1$, i.e., $$\frac 1{|S_n|}\sum_{\sigma\in S_n}f(\sigma)=1$$
b. Find the average value of $f(\sigma)^2$.
All that comes to my mind is to use Inclusion Exclusion Principle to calculate the number of combinations for a given value of $f(\sigma)$. That is, explicitly calculate the number of permutations of $X$ with exactly $r$ fixed points, denoted by $S_n(r)$. But, that is not a very easy task since we are doing it for a general $n$ which means $S_n(r)$ will be in the form of a summation, all of which needs to be summed again over all $r$. Also, this approach is not quite elegant. It becomes a real headache however in b since there you need to take a square as well. Also, we are never really using any property of permutation groups while solving this problem.
Is there any other approach that can make life easier?
While it is suggested in the comments and in an answer to use expectations of random variables, I don't think that is what the question asks of me considering the fact that the course in which I got the problem (it's a group theory course by the way) is far away from that. Is there any other ways to go about it?
Let $G$ be a group, $X$ a set, and:
\begin{alignat}{1} G\times X&\longrightarrow& X \\ (g,x)&\longmapsto& gx \\ \tag 1 \end{alignat} a $G$-action on $X$. Then:
Claim. For $X_i=X$ $(i=1,\dots,k)$, $\Pi X:=\prod_{i=1}^kX_i$, and $\bar x:=(x_1,\dots,x_k)\in\Pi X$, the map:
\begin{alignat}{2} G\times\Pi X&\longrightarrow &&\space\Pi X \\ (g,\bar x)&\longmapsto &&\space g\star \bar x:=(gx_1,\dots,gx_k) \\ \tag 2 \end{alignat}
is a $G$-action on $\Pi X$.
Proof. We have to confirm that the map "$\star$" fulfils the two properties for a group action. In fact:
The pointwise stabilizer for the action "$\star$" reads:
\begin{alignat}{1} \operatorname{Stab}_\star(\bar x) &= \{g\in G\mid g\star\bar x=\bar x\} \\ &= \{g\in G\mid (gx_1=x_1)\wedge\dots\wedge(gx_k=x_k)\} \\ &=\bigcap_{i=1}^k\operatorname{Stab}(x_i) \\ \tag 3 \end{alignat}
Furthermore:
\begin{alignat}{1} \operatorname{Fix}_\star(g) &= \{\bar x\in \Pi X\mid g\star\bar x=\bar x\} \\ &= \{\bar x\in \Pi X\mid (gx_1=x_1)\wedge\dots\wedge(gx_k=x_k)\} \\ \tag 4 \end{alignat}
whence $\bar x\in \operatorname{Fix}_\star(g)\iff x_i\in\operatorname{Fix}(g), i=1,\dots,k$. So, every $k$-tuple ($=$ ordered arrangement of $k$ elements of a set, where repetition is allowed) of elements of $\operatorname{Fix}(g)$ gives rise to a $\bar x\in \operatorname{Fix}_\star(g)$, and viceversa. Thus, for finite $X$:
$$\left|\operatorname{Fix}_\star(g)\right|=\left|\operatorname{Fix}(g)\right|^k \tag 5$$
(see this Wiki page, section "Permutations with repetition").
For your case b, take $G=S_n$, $X=\{1,\dots,n\}$ and $k=2$. By $(3)$, $\operatorname{Stab}_\star((i,j))=\operatorname{Stab}(i)\cap\operatorname{Stab}(j)$, whence $\left|\operatorname{Stab}_\star((i,j))\right|=(n-1)!$ for $j=i$, and $\left|\operatorname{Stab}_\star((i,j))\right|=(n-2)!$ for $j\ne i$. Therefore, there must be precisely two orbits for the action "$\star$"$^\dagger$. Now, by applying Burnside's Lemma to the action "$\star$":
$$\frac{1}{|S_n|}\sum_{\sigma\in S_n}\left|\operatorname{Fix}_\star(\sigma)\right|=2 \tag 6$$
and finally, by recalling $(5)$:
$$\frac{1}{|S_n|}\sum_{\sigma\in S_n}\left|\operatorname{Fix}(\sigma)\right|^2=2 \tag 7$$
which is your point b. (Your point a is the same result applied to the transitive action on one single copy of $X$.)
$^\dagger$In fact, by the Orbit-Stabilizer Theorem, $\left|\operatorname{Stab}_\star((i,j))\right|=(n-1)!$ implies $\left|O_\star((i,j))\right|=n$, and $\left|\operatorname{Stab}_\star((i,j))\right|=(n-2)!$ implies $\left|O_\star((i,j))\right|=n(n-1)$. But the set of orbits is a partition of the acted on set, whose size is $n^2$, whence $kn+ln(n-1)=n^2$ or, equivalently, $k+l(n-1)=n$. For $n=2$, this yields $k+l=2$; for $n>2$, $l=\frac{n-k}{n-1}$ integer implies $k=1$, which in turn implies $l=1$, and then again $k+l=2$. So, the action "$\star$" has two orbits for every $n\ge 2$.