In a class of $m$ students, what is the chance that $n$ will receive their own exam back

combinatoricsderangementsprobability

I have searched for and found similar questions, but none of them that I found answer this general case.

A class of $m$ students sit an exam. The exams are then handed back to the teacher and shuffled randomly. The exams are then handed back to the students in a random order.

What is the probability that $n$ of the students (for $0≤n≤m$) receive their own exam back?

My thought is that there are $m!$ ways that the exams could be handed back to the students. If we suppose that $n$ receive their own exam back, then there are now $(m-n)!$ ways that the remaining exams could be handed back. So the probability will be similar to $\frac{(m-n)!}{m!}$. I know that isn't correct, but I can't figure out how to account for the fact that if $(m-1)$ students receive their own exams back then necessarily all $m$ will reveive their own (because if $m-1$ get their's back then there is only one left for the last student).

Also, how would this be different if we were finding the probability that exactly $n$ out of $m$ receive their own exam back? I suppose that it would involve dividing the previous probability by $(m-n)!$ ?

Thanks, your help is appreciated.

Best Answer

This is called a partial derangement, and the number of ways of re-arranging $n$ items such that exactly $m$ are left in the same place is known as a reccontres number ("reccontre" is the French word for "encounter"). There is a Wikipedia article on rencontres numbers

Related Question