I need to find the probability that a random permutation of n elements has exactly k fixed points but I am confused on how to do so.
I have found this formula but I don't understand how to derive it. $D_{n,k}= \frac{n!}{k!}\sum_{i=0}^{n-k}\frac{(-1)^i}{i!}$
I know there are $nCk$ choices for the k fixed points but don't know how to calculate the number of derangement's on the remaining $n-k$ elements. I know that the total number of permutations is $n!$ so I will need to divide the above formula by $n!$ to find the total probability.