0% found this document useful (0 votes)
61 views5 pages

21 Pie: The Principal of Inclusion and Exclusion: (This Section Optional)

The Principal of Inclusion and Exclusion provides a general formula for counting the number of objects (V) that have one or more properties (a, b, c, etc.). The formula is: V = ΣN(properties) - ΣN(pairs) + ΣN(triples) - ... ± N(all properties). Where N represents the number of objects having the given properties. Several examples are provided to illustrate applying the PIE formula to problems involving counting coin toss sequences and derangements.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views5 pages

21 Pie: The Principal of Inclusion and Exclusion: (This Section Optional)

The Principal of Inclusion and Exclusion provides a general formula for counting the number of objects (V) that have one or more properties (a, b, c, etc.). The formula is: V = ΣN(properties) - ΣN(pairs) + ΣN(triples) - ... ± N(all properties). Where N represents the number of objects having the given properties. Several examples are provided to illustrate applying the PIE formula to problems involving counting coin toss sequences and derangements.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Chapter 21 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M.

Cargal

21
PIE:
The Principal of Inclusion and Exclusion
(This section optional)

The law of addition of Section 20 is a probabilistic interpretation of the principal of


inclusion and exclusion. In general, the problem of counting things is to count each object once
and only once. Suppose we have N objects, some of which have property a and some which
have property b and some of which have both properties. We will denote by Na the number of
objects with property a (some of which may also have property b). Nb is defined similarly with
Nab being the number of objects with both properties a and b. Vab denotes the number of objects

with property a or b. Then it follows that .

The rationale is precisely the same as for the law of addition. Since the Nab objects are counted
by both Na and Nb we must subtract Nab once.

By applying the formula recursively we can solve for Vabc.

Doing this we get . Going further we can

derive the general solution for Vabc...n:

The Principal of Inclusion and Exclusion

1
Chapter 21 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal

The general pattern of the formula is that for each set of properties, s, we add or subtract Ns. If
the number of properties in s is odd, we add Ns, otherwise we subtract Ns. If we denote by N0
the number of objects with none of the properties, we have N0 = N ! Vabc...n. A proof of the
formula of inclusion and exclusion is given in the next paragraph for those of you who are hardy.
The rest of you should feel free to skip to the following examples.
Consider an arbitrary object, call it X, out of our set of N objects. Suppose that this
object has k properties (out of however many properties we have). To prove that the formula
given by the principal of inclusion and exclusion is correct, we need only to show that X is

counted once and only once by the formula. X is counted k (= ) times by terms of the form

Nz. It is then counted times by terms of the form Nyz. In general it is counted times

by terms with j subscripts. Hence the total number of times it is counted is

. However, 1 ! h is the binomial expansion of

(1 ! 1)k = 0. That is, 1 ! h = 0, which means that X is counted h = 1 times.

Example Suppose we flip a coin 5 times. We would like to know how many ways can we
do this such that there is a sequence of exactly 3 heads in a row (4 heads in a row
doesn't count). Let Ni be the number of sequences of tosses with a sequence of
exactly 3 heads beginning on the i'th throw. We want to calculate V12345.
However, this is equal to V123 since a sequence of 3 heads cannot start on the 4'th
or 5'th throws. Applying the PIE formula we get
. Only the first 3 terms can be non-

zero since the other terms are self-contradictory. (Since for example we can't
have sequences of heads beginning on the first and the second throws.) N1 is the

2
Chapter 21 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal

number of sequences beginning with exactly 3 heads. The fourth throw must be
tails and this leaves two possibilities for the fifth throw. Hence, N1 = 2.
Similarly, if there is a sequence of exactly 3 heads beginning with the second toss
then both the first and fifth tosses must be tails. Hence, N2 = 1. Lastly if such
a sequence of heads begins on the third throw, the second throw must be tails and
the first throw can be either heads or tails. This gives N3 = 2. Hence,
V12345 = V123 = 5.

Example Consider the previous example except that we want to know the number of
sequences with 3 heads in a row or more. Now we want Ni to be the number of
sequences of tosses with a sequence of 3 or more heads beginning on the i'th
throw. As before, V12345 = V123 and .

Also as before, only the first three terms can be non-zero. This time N1 = 4 since
the fourth and fifth tosses can each be heads or tails. N2 = 2 since the fifth throw
can be heads or tails. Similarly, N3 = 2 because the first throw can be heads or
tails (but the second throw must be tails). V12345 = V123 = 8.

Example Consider the same problems as in the previous two examples but for eight tosses
of the coin. In the first case, we will count the number of sequences containing
exactly three heads in a sequence. For this we get
. These terms are 24, 23, 23,

23, 23, 24, 1, 1, and 1 respectively. The total is 61. In the second case, we will
count the number of sequences containing three heads or more in a sequence.
Again, we get . This time

however the terms are 25, 24, 24, 24, 24, 24, 2, 2, and 1 respectively for a total of
107.

3
Chapter 21 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal

Great Example: The Problem of Derangements


This is a classic application of PIE. Be warned however, that the result depends
on a (single) formula from calculus. Suppose that a hundred professors attend
a conference. Suppose also that they are required to leave their cattle prods in
the cloakroom. However, the cloakroom attendant does not have stubs for cattle
prods, so he hands the prods back randomly. What is the probability that not one
professor gets back his (or her) own prod? We let N represent the number of
ways the prods can be handed back; that is N = 100!. If we can count the number
of ways, N0, that the prods can be handed back without any professor getting his

own, then the probability of no one getting back his own is . Let

Nabc be the number of ways that the prods can be handed back without persons
a, b, or c getting back their own prods. Then, the number of ways, N0, that no
o n e g e t s b a c k h i s o w n p r o d i s
. This can be simplified

by binomial coefficients to:

which in turn simplifies to:

. Dividing this by 100! we

get . This is the first 99 terms of the Taylor series

for (where e is the base of the natural logarithms or roughly 2.71828). In

general if we have n professors, the probability that a professor gets his own prod

4
Chapter 21 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal

back is . The probability that all n professors get back their own prods is .

But for n over about 5, the probability that no one gets back his own prod is

roughly and is therefore is independent of n.

You might also like