Uploaded by Evan Ator

Chapter 4 Combinatorics

advertisement
Chapter 4:
Counting Methods
Counting methods are everywhere
Product Rule
Consider a situation where order matters, so that (๐‘‚๐‘๐‘—๐‘’๐‘๐‘ก! ,
๐‘‚๐‘๐‘—๐‘’๐‘๐‘ก" ) is meaningfully different from (๐‘‚๐‘๐‘—๐‘’๐‘๐‘ก" , ๐‘‚๐‘๐‘—๐‘’๐‘๐‘ก! ).
Example Company's retirement plan: 8 different bond funds
and 12 different stock funds
• For your portfolio: you are allowed to pick one bond fund
and one stock fund
How many possible ways are there to pick a portfolio?
Product Rule
Product rule for ordered pairs: If there are ๐‘š choices
for the first action and ๐‘› choices for the second action,
the number of possible choices for both actions is ๐‘š๐‘›.
Generalized product rule: Suppose there are ๐‘˜ actions. If
there are ๐‘›! choices for the 1st , ๐‘›" choices for the 2nd
action, and so on through ๐‘›# actions for the ๐‘˜-th action, the
number of possible choices for the ๐‘˜ actions is given by the
product of the numbers of choices, which is ๐‘›! ๐‘›" … ๐‘›# .
Product Rule
Example Company's retirement plan: 8 different bond funds and
12 different stock funds
• For your portfolio: you are allowed to pick one bond fund and one
stock fund
How many possible ways are there to pick a portfolio?
= 8 x 12 = 96
Example Company's retirement plan: The retirement plan adds
money-market fund options, so now they have 8 bond funds, 12
stock funds, and 4 money-market funds.
How many ways are there to pick a portfolio with one bond fund,
one stock fund, and one money-market fund?
= 8 x 12 x 4 =384
Sum Rule
Sum rule: If there are ๐‘š choices for the first action, ๐‘› choices for the
second action, and only one of the actions can be taken, the number
of possible choices is ๐‘š + ๐‘› .
Example Retirement savings: If instead of choosing both a bond
fund (8 choices) and a stock fund (12 choices), you are restricted to
choose only one fund overall. What is the total number of possible
choices?
= 8+12 = 20
Generalized sum rule: Suppose there are ๐‘˜ actions. If there are ๐‘›!
choices for the 1st , ๐‘›" choices for the 2nd action, and so on through
๐‘›# actions for the ๐‘˜-th action, the number of possible choices when
only one action can be chosen is given by the sum of the numbers of
choices, which is ๐‘›! + ๐‘›" +…+ ๐‘›# .
Permutations and combinations
Consider a group of n distinct objects. How many ways are there to choose a
subset of size ๐‘˜ from the group?
The first question to ask yourself: Does order matter or not?
Example Board of Directors: Suppose there are 20 candidates for positions on a
corporate board of directors.
• How many ways are there to select a three-member board of directors (no titled
positions)? Order doesn’t matter!
• How many ways are there to select a three-member board of directors with
titles of President, Vice President, and Treasurer specified?
Order does matter! (Sue Pres, Joe VP, Kate Treas)
Example Stock Portfolio: Suppose there are 100 possible stocks.
• You want to invest equally in five stocks ( 20% in each). How many possible
portfolios are there? Order doesn’t matter!
• You want to form a 30%/25%/20%/15%/10% weighted portfolio of five stocks.
How many possible portfolios are there? Order does matter!
Permutations and combinations
An ordered subset of distinct choices is called a permutation, and
๐‘ƒ$,# = # ๐‘œ๐‘“ ๐‘๐‘’๐‘Ÿ๐‘š๐‘ข๐‘ก๐‘Ž๐‘ก๐‘–๐‘œ๐‘›๐‘  ๐‘œ๐‘“ ๐‘ ๐‘–๐‘ง๐‘’ ๐‘˜ ๐‘กโ„Ž๐‘Ž๐‘ก ๐‘๐‘Ž๐‘› ๐‘๐‘’ ๐‘“๐‘œ๐‘Ÿ๐‘š๐‘’๐‘‘ ๐‘“๐‘Ÿ๐‘œ๐‘š ๐‘› ๐‘œ๐‘๐‘—๐‘’๐‘๐‘ก๐‘ .
An unordered subset of choices is called a combination, and
๐ถ$,# = # ๐‘œ๐‘“ ๐‘๐‘œ๐‘š๐‘๐‘–๐‘›๐‘Ž๐‘ก๐‘–๐‘œ๐‘›๐‘  ๐‘œ๐‘“ ๐‘ ๐‘–๐‘ง๐‘’ ๐‘˜ ๐‘กโ„Ž๐‘Ž๐‘ก ๐‘๐‘Ž๐‘› ๐‘๐‘’ ๐‘“๐‘œ๐‘Ÿ๐‘š๐‘’๐‘‘ ๐‘“๐‘Ÿ๐‘œ๐‘š ๐‘› ๐‘œ๐‘๐‘—๐‘’๐‘๐‘ก๐‘ .
๐ถ!,# is often denoted
๐‘›
and read as " ๐‘› choose ๐‘˜ ”
๐‘˜
General formula for permutations: ๐‘› factorial over (๐‘› − ๐‘˜) factorial
๐‘ƒ!,# =
๐‘›!
๐‘›−๐‘˜ !
Permutations
Back to….Example Board of Directors: Suppose there are 20 candidates for
positions on a corporate board of directors.
• How many ways are there to select a three-member board of directors with
titles of President, Vice President, and Treasurer specified?
Need to determine the number of permutations of size 3 that can be formed
from 20 objects.
๐‘ƒ$%,& =
20!
20! 20×19×18×17 …
=
=
= 6840
20 − 3 ! 17!
17×16×15 …
Example Stock Portfolio: Suppose there are 100 possible stocks.
• You want to form a 30%/25%/20%/15%/10% weighted portfolio of five stocks.
How many possible portfolios are there?
๐‘ƒ'%%,( =
100!
= 100 99 98 97 96 = 9,034,502,400
95!
Permutations in R
Combinations
Back to….Example Board of Directors: Suppose there are 20 candidates for
positions on a corporate board of directors.
How many ways are there to select a three-member board (with no titles)?
Need to determine the number of combinations of size 3 that can be formed
from 20 objects, or
20
๐ถ$%,& or
read as " 20 choose 3 ”
3
We know there are ๐‘ƒ$%,& permutations but notice that several of these
permutations are the “same” in an unordered setting.
Think about three candidates Jim, Kate, and Lucy, who would appear a total of six
times within the ๐‘ƒ$%,& permutations:
( ๐ฝ, ๐พ, ๐ฟ ) , ( ๐ฝ, ๐ฟ, ๐พ ) , ( ๐พ, ๐ฝ, ๐ฟ ) , ( ๐พ, ๐ฟ, ๐ฝ ) , ( ๐ฟ, ๐ฝ, ๐พ ) , ( ๐ฟ, ๐พ, ๐ฝ )
Notice this is k factorial – 3!=3*2*1=6
Combinations
General formula for combinations:
๐ถ$,#
๐‘›!
๐‘›
=
=
๐‘˜
๐‘› − ๐‘˜ ! ๐‘˜!
Back to…How many ways are there to select a three-member board (with no
titles)?
๐ถ"&,'
20!
20 ∗ 19 ∗ 18
20
=
=
=
= 1,140
3
17! 3!
3∗2∗1
Permutation ๐‘ƒ$%,&
Back to Example Stock Portfolio…How many ways are there to form an equally
weighted five-stock portfolio ( 20% each)?
๐ถ'%%,( =
100!
100 ∗ 99 ∗ 98 ∗ 97 ∗ 96
100
=
=
= 75,287,520
5
95! 5!
5∗4∗3∗2∗1
Combinations in R
Back to…How many ways are there to select a three-member board (with no
titles)?
Probabilities for equally likely choices
In some situations, you might want to ask about the probability of seeing
certain permutations or combinations
In the case where any permutation or combination is equally likely, it is often
possible to figure out the probability using math or using simulation methods.
For now, let's focus on what's possible with math.
Probabilities for equally likely choices
Example Website Names Shorter website names are more valuable. In fact, it's highly unlikely
that you would find a three-character website available for registration.
1. How many three-character websites are there? (By “character,” we mean any letter a through z
or number 0 through 9 .)
26 letters (a –z) and 10 numbers 0-9 = 36. 36 for
1st char, 36 for 2nd char, 36 3rd char
36 36 36 = 36!
2. If one of these websites is chosen at random (each with the same chance), what is the
probability that the website is composed entirely of alphabetic characters (no numbers)?
# ๐‘œ๐‘“ ๐‘™๐‘’๐‘ก๐‘ก๐‘’๐‘Ÿ๐‘  = 26 26 26 = 26!
Probability =
#$!
!$!
≈0.377
3. If one of these websites is chosen at random (each with the same chance), what is the
probability that the website has three distinct alphabetic characters?
# of these is permutation ๐‘ƒ$),& = (26)(25)(24)
Probability =
(#$)(#&)(#')
!$!
≈0.334
Probabilities for equally likely choices
Back to Example Stock portfolio: Consider again the problem of forming a 5-stock equally
weighted portfolio from 100 possible stocks, but now suppose that 20 stocks are classified as
“tech” stocks and 80 stocks as “non-tech” stocks.
How many equally weighted 5-stock portfolios have exactly 2 “tech” stocks and 3 “non-tech”
stocks?
Order of 2 T and 3 NT does not matter - combination
Desired portfolio is of the form ( ๐‘‡, ๐‘‡, ๐‘๐‘‡, ๐‘๐‘‡, ๐‘๐‘‡ ) , where ๐‘‡ = ๐‘ก๐‘’๐‘โ„Ž & ๐‘๐‘‡ = ๐‘›๐‘œ๐‘› ๐‘ก๐‘’๐‘โ„Ž
20
80
and for 3 non tech stocks # of ways:
2
3
20 80
Total number of portfolios is =
3
2
For 2 tech stocks # of ways:
If you form a portfolio by picking five stocks (from the 100) at random, what is the probability that
you have two or three “tech” stocks in the portfolio?
Recall that the total number of possible portfolios is
# with 2 T or 3 T = # with 2 T + # with 3 T =
prob =
$%
$
20
2
*%
$%
+
&
&
'%%
(
100
, which is the denominator here
5
80
20
+
3
3
*%
$
80
2
Probabilities for equally likely choices
Example The likelihood of “streaks”: Suppose that you flip a coin 100 times. What is
the probability of having a streak of (at least) five consecutive heads within the 100
tosses?
It's very difficult, though not impossible, to solve this problem using math. So, an
alternative approach is to use computer simulations:
Step 1: Simulate the experiment of flipping 100 coins.
Step 2: Check whether or not there is a streak of five heads within the simulated 100
flips.
Step 3: Repeat Steps 1 and 2 many times to determine the frequency (fraction) of times
that a streak of five heads occurs within 100 flips.
The following R code and output illustrates how to do it. The code conducts 100,000
simulations in order to approximate the desired probability.
Example The likelihood of “streaks” R code:
# of simulations
# of tosses
Frequency of 5 head streaks over 100,000 experiments
Example The likelihood of “streaks” R code:
Noise in estimating frequency
0.81156
Settles down
Download