Hat Check Problem Calculator

P(match) → 1 − 1/e

CalculatorsFreeNo Signup
4.3(104 reviews)
All Tools

Loading tool...

About Hat Check Problem Calculator

A hat check problem calculator exploring the classic probability puzzle: n hats randomly returned, what's P(at least one match)? Answer: 1-1/e ≈ 63.2% as n→∞. Uses derangement count !n = n!·Σ(-1)^k/k!. Related to inclusion-exclusion principle. Client-side.

Hat Check Problem Calculator Features

  • P(≥1 match)
  • P(exactly k)
  • Derangement count
  • 1/e convergence
  • Expected matches
Hat check problem: n people check hats, hats returned randomly. P(at least one match) = 1-!n/n! = 1-Σ(-1)^k/k! → 1-1/e ≈ 0.6321 as n→∞. Remarkably, the answer is nearly independent of n for n≥3!

How to Use

Enter n:

  • P(≥1): Match probability
  • !n: Derangement count
  • Expected: E[matches]=1

The Surprise

For n=3: P≈0.667. For n=10: P≈0.6321. For n=100: P≈0.6321. The probability converges to 1-1/e ≈ 63.21% incredibly fast. This counter-intuitive stability is because the alternating series Σ(-1)^k/k! converges rapidly.

Expected Matches

E[number of matches] = 1, ALWAYS, regardless of n! By linearity of expectation: each person has 1/n chance of getting their hat, and n × 1/n = 1. This is simpler than the probability calculation.

Step-by-Step Instructions

  1. 1Enter n.
  2. 2Compute P(≥1 match).
  3. 3See derangements.
  4. 4Check convergence.
  5. 5Compare to 1/e.

Hat Check Problem Calculator — Frequently Asked Questions

Why does the probability converge so fast?+

P(no match) = !n/n! = Σ_{k=0}^{n}(-1)^k/k!. This is the partial sum of e^{-1} = Σ(-1)^k/k!. The alternating series converges to 1/e with error < 1/(n+1)!, which is negligible even for n=5.

What's the distribution of matches?+

P(exactly k matches) = (1/k!)·Σ_{j=0}^{n-k}(-1)^j/j!. For large n: P(k matches)→e^{-1}/k! = Poisson(1) distribution. The number of matches is approximately Poisson with mean 1!

What are real-world applications?+

Secret Santa (random assignment), genetic matching, database record linkage quality, randomized controlled trials (checking for accidental matching). Any situation where random assignment might accidentally recreate the original.

Share this tool: