User:Chris-martin β public domain · Public Domain · Wikimedia Commons
When you want the probability that at least one of several events happens and the events overlap, just summing $P(A_i)$ double-counts the pairs, triple-counts the triples, and so on. PIE corrects it with alternating signs: add the singles, subtract the pairs, add the triples. We’ll use it on the classic derangement puzzle — the same engine handles “avoid all forbidden patterns” problems.
β Intro Β· expand
Try first (productive failure)
Before the worked example: spend 60 seconds taking your best shot at this.
A guess is fine β being briefly wrong about a problem makes the explanation
land harder when you read it. This appears once per tutorial; skip
if you already know the trick.
60s
β Try first Β· expand
Worked example
Four people throw their hats into a pile, then each picks one hat back uniformly at random. What is the probability that no one gets their own hat β i.e., the resulting permutation is a derangement?
β Worked example Β· expand
Practice 1 of 3Type a fraction, decimal, or expression β mathjs parses it.
β Practice Β· expand
Reflection
When you read a problem, what cue tells you to reach for inclusion-exclusion rather than (say) the simple complement or a recursion? In your own words, <em>why</em> do the signs alternate — what exactly is each term correcting from the term before it?