Quant Memo
Core

The Inclusion-Exclusion Principle

A counting rule for finding the size of a union of overlapping sets without double-counting the overlaps — add up each set's size, subtract every pairwise overlap, add back every triple overlap, and so on, alternating signs.

Prerequisites: Binomial Coefficients and Pascal's Triangle

If you want to count "how many traders use either Bloomberg or Reuters (or both)," simply adding the number who use Bloomberg to the number who use Reuters overcounts everyone who uses both — they get counted twice. Subtracting the overlap once fixes this for two sets, but with three or more overlapping groups, the double-counting and under-counting compounds in layers, and a single subtraction is no longer enough. Inclusion-exclusion is the general rule for correctly counting a union of any number of overlapping sets, no matter how many layers of overlap there are.

An analogy: painting a shared wall from multiple buckets

Imagine three painters each cover overlapping sections of one long wall with their own color. If you tried to compute "total wall covered" by simply adding each painter's individually-covered length, you'd count every doubly-covered patch twice and every triply-covered patch three times. Subtracting off each pair of painters' shared overlap corrects the double-counting — but doing so also removes the triply-covered patch three times over (once for each pair it belongs to), on top of the three times it was added originally, net zero — so it needs to be added back in once more to land on the correct total. This add, subtract, add-back pattern, continuing for as many painters as there are, is exactly inclusion-exclusion.

The principle, one symbol at a time

For sets A1,A2,,AnA_1, A_2, \dots, A_n, the size of their union is

i=1nAi=iAii<jAiAj+i<j<kAiAjAk+(1)n+1A1An.\left|\bigcup_{i=1}^n A_i\right| = \sum_i |A_i| - \sum_{i<j} |A_i \cap A_j| + \sum_{i<j<k} |A_i \cap A_j \cap A_k| - \cdots + (-1)^{n+1}|A_1\cap\cdots\cap A_n| .

In plain English: add up every individual set's size, then subtract the size of every pairwise overlap (fixing the double-counting), then add back every triple overlap (fixing what the pairwise subtraction over-corrected), then subtract every quadruple overlap, alternating sign, all the way up to the overlap of all nn sets together. For just two sets this reduces to the familiar AB=A+BAB|A \cup B| = |A| + |B| - |A \cap B| — the general formula is simply this idea extended to however many sets are actually overlapping.

Worked example 1: two overlapping groups

Among 100 traders, 60 use Bloomberg, 45 use Reuters, and 20 use both. How many use at least one? AB=60+4520=85|A\cup B| = 60+45-20 = 85. Direct check: 40 use only Bloomberg (60−20), 25 use only Reuters (45−20), and 20 use both, giving 40+25+20=8540+25+20=85 — matching, and confirming that simply adding 60+45=105 would have overcounted the 20 dual-users by exactly one extra count each, which the single subtraction of 20 correctly removes.

Worked example 2: three overlapping strategies

A fund runs three signals; over 200 trading days, momentum fires on 90 days, mean-reversion on 70 days, carry on 50 days. Momentum and mean-reversion both fire on 30 days; momentum and carry on 20 days; mean-reversion and carry on 15 days; all three fire together on 8 days. How many days does at least one signal fire? Apply the formula: 90+70+50(30+20+15)+8=21065+8=15390+70+50 - (30+20+15) + 8 = 210 - 65 + 8 = 153. Check the logic on the triple-overlap days: those 8 days were added three times (once in each of 90, 70, 50), then subtracted three times (once in each of the three pairwise overlaps of 30, 20, 15, each of which contains all 8 triple-overlap days), netting to zero coverage of those days so far — the final +8+8 restores them to being counted exactly once, as required.

A: 90 B: 70 C: 50 A∩B∩C: 8 A∩B: 30 B∩C: 15 A∩C: 20
Each overlapping region gets counted once too many or too few by naive addition; inclusion-exclusion's alternating add/subtract/add-back pattern corrects every layer of overlap exactly once.

What this means in practice

Inclusion-exclusion appears constantly in interview probability questions (birthday-style collision problems, "probability at least one of several events happens"), in risk aggregation (counting scenarios where at least one of several risk limits is breached), and in signal research (how many days at least one of several independent trading signals fires, as above). It's also the standard tool for deriving the probability of a union of non-independent events, since P(AB)=P(A)+P(B)P(AB)P(A \cup B) = P(A)+P(B)-P(A\cap B) is just inclusion-exclusion applied to probabilities instead of counts.

To count a union of overlapping sets correctly, add each set's size, subtract every pairwise overlap, add back every triple overlap, and continue alternating signs through every level of overlap — skipping any level (most commonly, forgetting the triple-overlap correction once there are three or more sets) leaves the count systematically wrong.

The most common mistake is stopping after the pairwise-subtraction step when there are three or more sets — this correctly removes double-counted regions but leaves triple-overlap regions under-counted (as shown in the worked example, where skipping the "+8" correction would have left the answer at 145 instead of the correct 153). Always check how many sets are actually involved and carry the alternating sum out to the full overlap of all of them, not just pairs.

Related concepts

Practice in interviews

Further reading

  • Feller, An Introduction to Probability Theory and Its Applications, ch. 4
  • Graham, Knuth & Patashnik, Concrete Mathematics, ch. 5
ShareTwitterLinkedIn