MathLabs

Problem 1

Let pn(k)p_n(k) be the number of permutations of the set {1,…,n}\{1, \ldots, n\}, n≥1n \ge 1, that have exactly kk fixed points. Prove that ∑k=0nk⋅pn(k)=n!\sum_{k=0}^{n} k \cdot p_n(k) = n!. (A permutation ff of a set SS is a one-to-one mapping of SS onto itself; an element ii of SS is a fixed point of ff if f(i)=if(i) = i.)
Step 2 of 4: Linearity of expectation gives E[X] = 1
In plain words

Linearity of expectation lets us add up each element's individual chance of being fixed, even though the events are not independent.

X=∑i=1n1{f(i)=i},E[X]=∑i=1nP(f(i)=i)=n⋅1n=1X = \sum_{i=1}^{n} \mathbf{1}_{\{f(i)=i\}}, \qquad \mathbb{E}[X] = \sum_{i=1}^{n} P(f(i)=i) = n \cdot \frac{1}{n} = 1
Detailed analysis

Let XX denote the (random) number of fixed points of ff, so X=∑i=1n1{f(i)=i}X = \sum_{i=1}^n \mathbf{1}_{\{f(i)=i\}}, a sum of indicator variables. Linearity of expectation holds regardless of dependence between the indicators, so E[X]=∑i=1nP(f(i)=i)=n⋅1n=1\mathbb{E}[X] = \sum_{i=1}^{n} P(f(i)=i) = n\cdot\frac{1}{n} = 1.