### Derangement - Complete FAIL!

**Source**: Interview at one of the quant firms

**Problem**:

As posted in problems this and this, this is an extension to the derangement problem.

There are

*n*men,

*n*hats, one hat belonging to each person. A random permutation of hats is picked by the men. What is the probability that no person gets the correct hat?

Update (March 6, 2011)

**Solution:**Posted by Vipul Verma (Engineer at Portware, IIT KGP and University of South California Alumnus) in comments!

The number of arrangements so that no one gets his own hat = n!*(1 - 1/1! + 1/2! - 1/3! + 1/4! ..... + (-1)^n/n!)

ReplyDeleteTotal number of arrangements = n!

The prob that this happens = (1 - 1/1! + 1/2! - 1/3! + 1/4! ..... + (-1)^n/n!)

Easy one....

Yes, easy one. Direct application of Inclusion Exclusion Principle. :)

ReplyDeleteBut your answer is wrong.

Prob that no one gets his own hat = 1 - (Prob that at least one correct hat) = 1 - (nC1*1/n - nC2*1/(n*n-1) +..) = 1 - (1 - 1/2! + 1/3! .. ) = 1 - 1/e

Prob: 1-1/e

Your solution gives the probability that at least one person gets the correct hat.

Pratik, how is my answer wrong? How my soln is giving the prob. that at least one person gets the correct hat.

ReplyDeleteIf you look closely the expression you have got is same as what I got. The only difference is that expression has infinite terms which I don't understand why.

Your series should not go to infinity. It should stop at n.

Pratik, if you see yours and vipul's answer are actually same.

ReplyDeleteI am sorry. My apologies.

ReplyDeleteYes your solution is correct. Our answers are same. Also, I should not have taken infinite terms. Thanks.

1 - 1/2! + 1/3! .. = 1 - 1/e, and so the prob for no one get it right should be 1/e, right...?

ReplyDelete@Yun.

ReplyDeleteYes you are correct.

For large n

Prob that no one gets his own hat = 1 - (Prob that at least one correct hat) = 1 - (nC1*1/n - nC2*1/(n*n-1) +..) = 1 - (1 - 1/2! + 1/3! .. ) = 1 - (1-1/e)

Prob: 1/e