Fiveable

🧮Combinatorics Unit 5 Review

QR code for Combinatorics practice questions

5.3 Derangements and the hat-check problem

5.3 Derangements and the hat-check problem

Written by the Fiveable Content Team • Last updated August 2025
Written by the Fiveable Content Team • Last updated August 2025
🧮Combinatorics
Unit & Topic Study Guides

Derangements and the hat-check problem are fascinating applications of the Principle of Inclusion-Exclusion. They show how we can count permutations where no element stays in its original spot, like shuffling a deck so no card's in the same place.

These concepts help us solve real-world problems, like figuring out the odds of everyone getting the wrong hat at a party. It's a fun way to see how math can predict seemingly random events in our everyday lives.

Derangements and Inclusion-Exclusion

Defining Derangements

  • Derangements represent permutations of a set where no element appears in its original position
  • Closely related to the Principle of Inclusion-Exclusion (PIE) used to calculate the number of elements in the union of multiple sets
  • Viewed as the complement of permutations with fixed points making them suitable for PIE analysis
  • Number of derangements of an n-element set denoted by D(n) or !n (subfactorial n)
  • Probability of a random permutation being a derangement approaches 1/e as n approaches infinity
  • Applications span various fields (probability theory, combinatorics, computer science)

Examples and Applications

  • Derangement scenario (shuffling a deck of cards ensuring no card returns to its original position)
  • Hat-check problem (returning n hats to n people without anyone receiving their own hat)
  • Matching problem (assigning n tasks to n workers where no worker receives their usual task)
  • Secret Santa gift exchange (ensuring no participant gives a gift to themselves)
  • Rook placements on a chessboard (placing n rooks on an n×n board with no rook on the main diagonal)
  • Cryptography (designing permutation ciphers without fixed points)

Derangement Formula Derivation

Defining Derangements, algebra precalculus - Please help to complete proof of inclusion and exclusion principle ...

Applying the Principle of Inclusion-Exclusion

  • Formula for the number of derangements D(n)=n!(11/1!+1/2!1/3!+...+(1)n/n!)D(n) = n! * (1 - 1/1! + 1/2! - 1/3! + ... + (-1)^n/n!)
  • Derivation starts by considering total permutations (n!) and subtracting permutations with fixed points
  • PIE application accounts for overlaps in sets of permutations with multiple fixed points
  • k-th term in PIE expansion represents permutations with at least k fixed points chosen in (nk){n \choose k} ways
  • Resulting expression simplifies to closed-form formula for D(n)
  • Formula verification for small n values ensures correctness and understanding

Step-by-Step Derivation Process

  • Begin with the total number of permutations n!n!
  • Subtract permutations with at least one fixed point n!(n1)(n1)!n! - {n \choose 1}(n-1)!
  • Add back permutations with at least two fixed points n!(n1)(n1)!+(n2)(n2)!n! - {n \choose 1}(n-1)! + {n \choose 2}(n-2)!
  • Continue alternating subtraction and addition for k fixed points up to n
  • Simplify the expression by factoring out n!
  • Recognize the resulting series as the Taylor expansion of e^(-1)
  • Arrive at the final formula D(n)=n!k=0n(1)kk!D(n) = n! * \sum_{k=0}^n \frac{(-1)^k}{k!}

Hat-Check Problem with Derangements

Defining Derangements, combinatorics - Permutation Theorem - Mathematics Stack Exchange

Classic Hat-Check Problem

  • Calculates probability of no person receiving their own hat when n hats are randomly returned
  • Equivalent to finding number of derangements of n items divided by total permutations (n!)
  • Probability of no person receiving their own hat D(n)/n!D(n)/n! approaches 1/e as n increases
  • Solution involves calculating D(n) using the derived formula
  • Numerical example (calculating probability for 5 people and hats)
  • Real-world applications (coat check systems, random assignment processes)

Hat-Check Problem Variations

  • Calculating probability of exactly k people receiving their own hats
  • Determining expected number of people who receive their own hats
  • Solving variations using combinations of derangements and permutations with fixed points
  • Applying concept of complementary events to simplify some calculations
  • Example (probability of at least one person receiving their own hat)
  • Extension to multi-object scenarios (returning both hats and coats to correct owners)

Derangement Asymptotic Behavior

Convergence Analysis

  • Ratio of derangements to total permutations D(n)/n!D(n)/n! converges to 1/e as n approaches infinity
  • Convergence proof uses Taylor series expansion of e^(-1)
  • Relatively fast convergence with accurate approximation for n > 10
  • Asymptotic behavior of D(n) expressed as D(n)n!/eD(n) \sim n!/e where ~ denotes asymptotic equivalence
  • Error term study in approximation and its rate of decay as n increases
  • Comparison to asymptotic behavior of other combinatorial sequences (Stirling numbers of the second kind)

Practical Implications and Applications

  • Approximating derangement probabilities for large n without exact calculation
  • Estimating number of derangements for large sets using asymptotic formula
  • Applications in large-scale randomization processes (shuffling algorithms)
  • Relevance to statistical analysis of permutation-based experiments
  • Connection to other limit behaviors in probability theory (Poisson approximation)
  • Computational considerations for calculating derangements of very large sets
Pep mascot
Upgrade your Fiveable account to print any study guide

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Click below to go to billing portal → update your plan → choose Yearly → and select "Fiveable Share Plan". Only pay the difference

Plan is open to all students, teachers, parents, etc
Pep mascot
Upgrade your Fiveable account to export vocabulary

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Plan is open to all students, teachers, parents, etc
report an error
description

screenshots help us find and fix the issue faster (optional)

add screenshot

2,589 studying →