Expected value (mean) tends to confuse me lately.
Let $ \Omega$ be the discrete space of all functions $ \omega:\{1,2,3,\dots,n\} \rightarrow\{1,2,3,\dots,n\}$, $\mbox{Pr}$ is uniformly distributed. Let $f$ be a random variable that counts all fixed points of all functions in $ \Omega $ $$ f(\omega) = |\{i \in \{1,2,3,...,n\}: \omega(i)=i\}$$
Well, I had two ideas which ended the same way. In both of them I defined n indicators $f_1,f_2,f_3...f_n$, such that for each $ 1\leq i\leq n$, return 1 if $f(i)=i$ and 0 otherwise. Than, the expected value is the sum of $ \sum_{i=1}^{n} f_i$
First idea
Looking at index i, the probability to choose i as an image is $Pr(fi=1)= \frac{1}{n}$ then the expected value is $\frac{1}{n}+\frac{1}{n}+\frac{1}{n}...+\frac{1}{n}=\frac{n}{n}=1$
Second idea
For index i there is one option, and for the rest of the indexes are free to be chosen, so $Pr(fi=1) = \frac{1 \cdot n^{n-1}}{n^n}$
Then the expected value is once again the sum, which is $ n \cdot \frac{n^{n-1}}{n^n} = \frac{n}{n}=1 $
Am I on the right track or totally lost?