##### Example on Probablity - 2 | MIT Assignment

The hats of n persons are thrown into a box. The persons then pick up their hats at random (i.e., so that every assignment of the hats to the persons is equally likely). What is the probability that

(a) every person gets his or her hat back?

(b) the first m persons who picked hats get their own hats back?

A)

Consider the sample space of all possible hat assignments.

It has n! elements (n hat selections for the first person, after that n − 1 for the second, etc.), with every single element event equally likely (hence having probability 1/n!).

The question is to calculate the probability of a single-element event, so the answer is 1/n!

B)

consider the same sample space and probability as in the solution of (A).

The probability of an event with (n−m)! elements (this is how many ways there are to distribute the remaining n − m hats after the first m are assigned to their owners) is (n − m)!/n!