Skip to content

Derangement

A permutation with no fixed points: count complete reassignments by inclusion-exclusion and distinguish the exact probability from the 1/e limit.

A derangement is a permutation of distinct objects in which none remains in its original position. It counts complete one-to-one reassignments when every original match is forbidden. For a uniformly random shuffle, the count gives the probability that every label moves.

Write π(i)\pi(i) for the label occupying slot ii. A fixed point occurs when π(i)=i\pi(i)=i; a derangement satisfies π(i)≠i\pi(i)\ne i for every slot. This is a restriction on positions, not on whether labels remain adjacent or form pairs.

Four labels, nine complete moves

Start with labels 1, 2, 3 and 4 in their matching slots. The arrangement (2,1,4,3)(2,1,4,3) is a derangement: two pairs swap. In contrast, (2,1,3,4)(2,1,3,4) is not, because labels 3 and 4 stay put. A derangement need not be one long cycle.

Of the 4!=244!=24 permutations, exactly nine have no fixed points. If all 24 are equally likely, the probability is
P(no fixed points)=924=38=37.5%.\mathbb{P}(\text{no fixed points})=\frac{9}{24}=\frac{3}{8}=37.5\%.
Nine four-label derangements are listed. Among all 24 permutations, the counts with zero, one, two, three and four fixed points are 9, 8, 6, 0 and 1. The no-fixed-point probability is 37.5%; the average fixed-point count is 1.
Nine four-label derangements are listed. Among all 24 permutations, the counts with zero, one, two, three and four fixed points are 9, 8, 6, 0 and 1. The no-fixed-point probability is 37.5%; the average fixed-point count is 1.
Exact enumeration of four distinct labels. Read each listed arrangement from slot 1 to slot 4; every label differs from its slot number.

Count by removing fixed points

Let DnD_n, also written !n!n, be the number of derangements of nn labels. For any specified kk slots, fixing their matching labels leaves (n−k)!(n-k)! ways to arrange the rest. There are (nk)\binom{n}{k} choices of these slots.

Simply subtracting permutations that fix each individual slot removes some permutations repeatedly. The inclusion-exclusion principle corrects these overlaps, alternately restoring and subtracting intersections:

Dn=∑k=0n(−1)k(nk)(n−k)!=n!∑k=0n(−1)kk!.D_n=\sum_{k=0}^{n}(-1)^k\binom{n}{k}(n-k)! =n!\sum_{k=0}^{n}\frac{(-1)^k}{k!}.
For four labels, this gives D4=24−24+12−4+1=9D_4=24-24+12-4+1=9. For five, D5=44D_5=44. The boundary counts are D0=1D_0=1 (one empty arrangement) and D1=0D_1=0. Dennis White's university notes derive the count using the same fixed-position events.
Counting and Combinatorics develops the factorial and binomial counting tools used here. Its public preview gives the outline; the full Library lesson requires membership.

What the probability does—and does not—say

Dividing by n!n! is valid under a uniform distribution over all permutations. Then
P(no fixed points)=∑k=0n(−1)kk!⟶e−1≈0.367879.\mathbb{P}(\text{no fixed points}) =\sum_{k=0}^{n}\frac{(-1)^k}{k!} \longrightarrow e^{-1}\approx0.367879.
The limit is about 36.8%36.8\%, not an exact finite-nn probability. For four labels, use 37.5%37.5\%. Berkeley's matching-problem chapter distinguishes the finite sum from this approximation.
Each slot has probability 1/n1/n of being fixed. Summing these probabilities shows that the expected number of fixed points is one for every n≥1n\ge1. That is an average over shuffles. The figure includes outcomes with zero, two and four fixed points. For n≥2n\ge2, different slots’ fixed-point events are dependent, so multiplying their individual no-match probabilities does not give the derangement probability.

A biased shuffle, extra forbidden assignments or indistinguishable objects changes the counting or probability model. In quantitative research, forbidding original label matches can define a reassignment scheme, but it does not itself justify a statistical permutation test: the null model must still permit those rearrangements.

Sources

Last updated
  • combinatorics
  • permutations
  • fixed points
  • inclusion exclusion
← Back to the glossaryBack to top ↑