im trying to solve the following question:
let σ∈Sn be a random permution of {1,2,.....,n} as Sn is the set of all permutions with n variables and let f(σ) be a random variable that counts the pairs swap in permutions
for example {1,2,3} -> {2,1,3} as 1 and 2 swapped.
as for E[f] i splitted f into nC2 random variables that indicates if a pair swapped and as result i got that E[f] = $\frac{1}{2}$
now im trying to solve Var[f]
as i tried to use Var[f] = E[$f^2$] - $(E[f])^2$ = E[$f^2$] - $\frac{1}{4}$
but i cant figure out how to calculate E[$f^2$] and how to check exactly that i got the right answer in the end. I would truly appreciate any help on computing this variance!