download

2
ENUMERATION
This section is based on Chapter 3 of a text by K. L. Chung1
So you think you know how to count? Consider the following problem: Suppose
you are the chief engineer at the Ellicott Dominoes domino factory. Dominoes are
rectangular tiles used in some parlor games and they look like Figure 2.1. Typically,
Figure 2.1: A single domino
dominoes have each half of a tile painted with 1 to 9 dots (called “pips”) or a blank
for a total of 10 possible choices.
Of course, a domino painted (1,4) can be turned 180 degrees to look like a domino
painted (4,1). So there is no need to have one assembly line producing (1,4)
dominoes and another producing (4,1) dominoes.2 How many different dominoes
does your factory actually produce? (Try this problem on your friends and see how
many different answers you get.)
In this chapter, we will present a systematic way to approach counting problems.
We will classify counting problems into four categories, and solve each type. In
practice, most counting problems can be approached using one or a combination
of these four basic types.
1
Chung, K. L., Elementary probability theory with stochastic processes, Springer-Verlag, New
York, 1975.
2
Just have a person at the end of the assembly line turning around half of the dominoes.
19
20
Sampling
Fundamental Rule
The following rule forms the foundation for solving any counting problem:
Multiplication Principle: Suppose there are several multiple choices to be made.
There are m1 alternatives for the first choice, m2 alternatives for the second, m3
for the third, etc. The total number of alternatives for the whole set of choices is
equal to
(m1 )(m2 )(m3 ) · · · .
Example: Suppose a engineering class has five women and four men. You would
like to select a research team consisting of one man and one woman. There are
four choices for selecting the man and five choices for selecting the woman. The
total number of possible research teams is, therefore, 4 · 5 = 20
Sampling
The Urn Model: Imagine an urn that contains n balls marked 1 to n. There are
four disciplines under which the balls can be drawn from the urn and examined.
I. Sampling with replacement and with ordering.
A total of m balls are drawn sequentially. After a ball is drawn, it is replaced
in the urn and may be drawn again. The order of the balls is noted. Hence the
sequence 1, 3, 2, 3 is distinguished from 3, 3, 1, 2. Since there are n possible
ways to draw the first ball, n possible ways to draw the second, etc., the total
number of possible sequences is
nm .
Example: Suppose you give a quiz with 5 questions, each with a possible
answer of True or False. Therefore, there are two ways to answer the first
question, two ways to answer the second question, and so on. The total
number of possible ways to answer all of the questions on the exam is
2 · 2 · 2 · 2 · 2 = 25 = 32.
II. Sampling without replacement and with ordering.
A total of m balls are drawn sequentially with m ≤ n. After a ball is drawn,
it is not replaced in the urn and hence cannot be drawn again. The order of
Sampling
21
the balls is noted. Since there are n possible ways to draw the first ball, n − 1
possible ways to draw the second, n − 2 possible ways to draw the third, etc.,
the total number of possible sequences is
n(n − 1)(n − 2) · · · (n − m + 1).
For the special case when m = n, the total number of possible ways to draw
n balls is
n(n − 1)(n − 2) · · · (2)(1) ≡ n!.
Note that when m = n, this is equivalent to the problem of counting the
number of ways you can arrange n different balls in a row.
Computational Hint: We can compute
n(n − 1)(n − 2) · · · (n − m + 1) =
n!
.
(n − m)!
By definition, 0! ≡ 1 so that when n = m, we have
n(n − 1)(n − 2) · · · (n − n + 1) =
n!
n!
=
= n !.
(n − n)!
0!
Example: Suppose you have five different birthday cards, and you have
three friends (named Bill, Mary, and Sue) with birthdays this week. You
want to send one card to each friend. The number of possible choices for
Bill’s card is 5. The card for Mary’s must come from the remaining 4 cards.
Finally, the number of possible choices for Sue’s card is 3. Hence the total
number of ways you can assign five birthday cards to your three friends is
5 · 4 · 3 = 60.
It’s interesting to note that the sequence of friends (Bill, then Mary, then Sue)
is arbitrary and does not affect the answer.
Here is another way to look at this problem: Consider the empty mailboxes
of your three friends,
? ? ?
B M S
If the cards are labelled a,b,c,d,e, then one possible assignment is
c d
B M
a
S
22
Sampling
There are 5 ways to fill the first position (i.e., Bill’s mailbox), 4 ways to fill
the second position and 3 ways to fill the third.
Example: Using the above example, we can compute the number of ways
one can arrange the three letters x, y, z. This time we have 3 positions to fill
with 3 different items.
? ? ?
1 2 3
So a possible arrangement is
y z x
1 2 3
and there are 3 · 2 · 1 = 3! = 6 possible assignments.
III. Sampling without replacement and without ordering.
A total of m balls (m ≤ n) are drawn from the urn. The balls are not replaced
after each drawing and the order of the drawings is not observed. Hence,
this case can be thought of as reaching into the urn and drawing m balls
simultaneously. The total number of ways a subset of m items can be drawn
from a set of n elements is
(1)
n!
≡
m!(n − m)!
à !
n
.
m
This number is often referred to as the binomial coefficient.
To derive the above formula, let x denote the number of ways to choose m
items from n items without replacement and without ordering. We can find
the value of x by considering Case II as a two-stage process:
Stage 1 Grab m items from n without replacement and without ordering.
Stage 2 Given the m items selected in Stage 1, arrange the m items in order.
Combined, the two stages implement Case II (sampling without replacement
and with ordering). Stage 1 (selecting the m balls) can be performed x ways,
our unknown quantity. Stage 2 (ordering the m balls) can be performed m!
ways (using Case II for m items drawn from m items).
Furthermore, we know, using Case II (with m items drawn from n items),
that the entire process of Stage 1 followed by Stage 2 can be performed in
Sampling
23
n!
(n−m)!
ways. Hence, we must have
x · m! =
n!
(n − m)!
In other words,
[Stage 1] · [Stage 2] = [Case II].
Solving for x then yields our result.
Computational Hint: Note that
à !
n
m
Ã
!
n!
n
n!
=
=
=
.
m!(n − m)!
(n − m)!m!
n−m
So, for example,
à !
à !
5
5
=
3
2
à !
and
à !
9
9
=
.
4
5
Also
note that if n is large, brute force computation of all three factorial terms
¡n¢
of m can be a challenge. To overcome this, note that
à !
n
m
=
n(n − 1)(n − 2) · · · (n − m + 1)
n!
=
.
m!(n − m)!
m!
with only m terms in both the numerator and the denominator. Hence,
Ã
!
10
10!
10 · 9
=
=
= 45
2
2!8!
2!
and
Ã
!
Ã
!
100
100
100!
100 · 99 · 98
=
=
=
= 161700.
97
3
3!97!
3!
Example: A consumer survey asks: Select exactly two vegetables from the
following list:
◦ peas
◦ carrots
◦ lima beans
◦ corn
The total number of ways you can select two items from the four is
¡4¢
2
= 6.
24
Sampling
IV. Sampling with replacement and without ordering.
This case is perhaps the most difficult to perceive as a sampling discipline,
yet it has important applications. A total of m balls are drawn sequentially
from the urn. Each ball is replaced after being drawn. However, the sequence
of the draws is ignored. Therefore, drawing 3, 3, 1, 2 is the same as drawing
1, 3, 2, 3. The number of ways that m balls can be drawn from an urn
containing n balls in this fashion is
Ã
!
m+n−1
.
m
Let’s prove that this formula works. First, note that to describe a possible
outcome from this scenario, we only need to know how many times each
ball was drawn. For example, to describe 3, 3, 1, 2 or 1, 3, 2, 3 we only need
to know that Ball 1 was drawn once, Ball 2 was drawn once, and Ball 3 was
drawn twice. This arrangement can be represented as follows:
1
2
3
3
1
√
2
√
3
√√
For another example using this scheme, the arrangements 2, 2, 2, 3 or 2, 3, 2, 2
and their counterparts would be represented as
1
2
2
2
3
2
√√√
3
√
Now notice that any of these outcomes can be represented by only specifying
√
the arrangement of the four check marks ( ) among the inner two vertical
lines (|). For example,
1
2
2
2
3
2
3
3
So, for example,
would represent 3, 3, 3, 3.
1
√
2
3
√ √√
√√√ √
√√√√
||
Coded
Representation
√ √ √√
| |
√√√ √
|
|
Sampling
25
To count the total number of possible outcomes, note that our coded representation has six positions
? ? ? ? ? ?
√
Any four of these can be selected for the check marks ( ) and the remaining
two will be filled with the two vertical lines
(|). The number of ways we
¡ ¢
can select 4 positions from 6 positions is 64 = 15. Therefore, there are 15
possible ways we can select 4 balls from an urn containing 3 balls if we allow
replacement and disregard ordering.
In general, if there are n balls and m drawings, we will need m check marks
√
( ). To represent all possible outcomes, our table will have n columns.
k1 k2 · · · kn
1
√√
2
√
···
···
n
√
Coded
Representation
√√ √
√
| |···|
Therefore, our coded representation will have m check marks and n − 1
vertical lines. So we need (n − 1) + m positions for both check marks and
vertical lines
? ? ? ··· ?
|
{z
}
(n − 1) + m
positions
The number of ways we can select m positions for check marks from (n −
1) + m positions is
Ã
!
n+m−1
m
Example: Mary wants to buy a dozen cookies. She likes peanut butter
cookies, chocolate chip cookies and sugar cookies. The baker will allow her
to select any number of each type to make a dozen. In this case, our table
has three columns with twelve check marks. So the following arrangement:
Peanut
Butter
√√
Chocolate
Chip
√√√
Sugar
√√√√√√√
Coded
Representation
√√ √√√ √√√√√√√
|
|
would represent the outcome when Mary selects 2 peanut butter, 3 chocolate
chip and 7 sugar cookies. In this case, we are arranging 14 symbols in a row:
26
Occupancy
2 vertical lines and 12 check marks. So the number of possible different
boxes of one dozen cookies is
Ã
!
Ã
!
Ã
!
12 + 3 − 1
14
14
14 · 13
=
= 91.
=
=
12
2·1
12
2
Permutation of n items distinguished by groups
An extension of case III is the situation where one has n balls with n1 of them
painted with color number 1, n2 of them painted with color number 2,. . . ,nk of
them painted with color number k . We have
k
X
ni = n.
i=1
If the balls are arranged in a row, the number of distinguishable arrangements is
given by
n!
.
n1 !n2 ! · · · nk !
This quantity is a generalization of the binomial coefficient and is called the multinomial coefficient. Note that when k = 2, this situation is the same as case
III.
Example: Consider the seven characters, A, A, A, B, B, C, C . The number of
distinct arrangements of these seven letters in a row is
7!
= 210.
3!2!2!
Occupancy
The Token Model: In sampling problems, we think of n balls placed in an urn from
which m balls are drawn. A direct analogy can be made with so-called occupancy
problems. In such models, we are given n boxes marked 1 to n, and m tokens
numbered 1 to m. There are four disciplines for placing the tokens in the boxes.
Each of these four scenarios correspond to one of the four sampling cases.
The reason for introducing occupancy problems becomes clear as one encounters
different counting problems. Some may be easier to conceptualize as occupancy
problems rather than sampling problems. Nevertheless, the number of distinguishable ways in which the tokens may occupy the boxes is computed in precisely the
same manner as in the sampling models.
Occupancy
27
The connection between the two formulations is easy to remember if you note the
following relationships:
Sampling Problems
Occupancy Problems
ball
number of drawing
j th draw yields ball k
box
number on token
j th token is placed in box k
For example, suppose we have a sampling problem with 3 balls (labelled a, b, c)
being drawn 4 times. This would correspond to an occupancy problem with 3
boxes and 4 tokens (See Figure 2.2). Moreover, the following outcomes from each
Tokens
1
Tokens
2
3
2
4
1
a
1
2
3
4
4
3
b
c
(a) Token labels observed
a
(b) Token labels not observed
Figure 2.2: The occupancy problem
model would be equivalent:
Sampling
Drawing Ball
1
b
2
a
3
b
4
c
Sampling cases I to IV can now be viewed as
b
Occupancy
Box Tokens
a
2
b
1,3
c
4
c
28
Occupancy
I*. Each box may contain any number of tokens and the labels on the tokens are
observed.
II*. No box may contain more than one token and the labels on the tokens are
observed.
III*. No box may contain more than one token and the labels on the tokens are not
observed.
IV*. Each box may contain any number of tokens and the labels on the tokens are
not observed.
The scheme with check marks and vertical bars that we used for Case IV is now
readily apparent. Each column of the table represents a box, and each check mark
represents a token.
Example: Suppose a school has five classrooms (with different room numbers)
and three teachers, Ms. Smith, Mr. Thomas and Ms. Warren. For some courses,
more than one teacher might be assigned to the same classroom.
I*. If more than one teacher can be assigned to a classroom, and it matters which
teacher teaches in a particular room, then the number of ways you can assign
teachers to classrooms is
nm = 53 = 125.
II*. If only one teacher can be assigned to a classroom, and it matters which teacher
teaches in a particular room, then the number of ways you can assign teachers
to classrooms is
n(n − 1) · · · (n − m + 1) = 5 · 4 · 3· = 60.
III*. If only one teacher can be assigned to a classroom, and it does not matter
which teacher teaches in a particular room, then the number of ways you can
assign teachers to classrooms is
à !
n
m
à !
=
5
= 10.
3
IV*. If more than one teacher can be assigned to a classroom, and it does not
matter which teacher teaches in a particular room, then the number of ways