Upload
hakhue
View
216
Download
0
Embed Size (px)
Citation preview
L18 2
Announcements� No HW due for Monday�MT2 Coming up one week from now� Study guide available at
www.cs.columbia.edu/~zeph/3203/exams/mt2studying.html
� Review session Sunday, 4/7, 4-6 pm 633 Mudd
� Tuesday will hold office hours from 11-1 to help with midterm
� No office hours Wednesday aftermiderm
L18 3
Agenda
� Section 4.3. More counting� r-permutations: P (n,r )� r-combinations: C (n,r )� Anagrams� Cards and Poker
� Section 4.4. Discrete Probability� The usefulness?? of playing the NY Lotto.
L18 4
Permutations and Combinations
Several ways of interpreting question“How many ways are there to buy 13
different bagels out of 17 types?”1st Interpretation: order matters2nd Interpretations: order doesn’t matter so
only care about set of bagels that have at the end, not about the purchasing instructions.
……………… same purchase
L18 5
Permutations and Combinations
Usually 2nd interpretation is taken, but in other situations, 1st interpretation makes more sense. EG: Suppose the bagels were destined to the 13 alphabetized children in a kindergarten.
………
Al Bina Charmaine Darlene
L18 6
First Interpretation:Number of r-permutations
Solution under 1st interpretation:
………
Al Bina Charmaine Darlene17 · 16 · 15 · 14 · … · 6·5
= 1713 where we introduce the falling power notation:x r =P (x,r ) = x (x-1)(x-2)(x-3)···(x-r+1)
L18 7
Number of r-permutationsAbstractly, P (n,r ) is defined as the cardinality of:
{ordered r-tuples with distinct coord’s from {1,2,3, …, n}}= {r-permutations of the set {1,2,3, …, n}} (by definition)
EG: P (3,2) is the number of 2-tuples with distinct coordinates taken from {1,2,3}, so is the cardinality of:
{(1,2),(2,1),(1,3),(3,1),(2,3),(3,2)}Which is 6 = 3·2.THM: The abstract definition of P (n,r ) is
calculated with the formula P (n,r ) = n r.Proof by bagels!!!! �
L18 8
Number of r-permutationsCounting 1-to-1 Functions
Q: Express the number of one-to-one functions from {1,2,3,…,m} to {1,2,3,…,n} by using the falling power.
L18 9
Number of r-permutationsCounting 1-to-1 Functions
A: From last time, this is just given by n m for m £ n and is 0 otherwise. Can see this directly, since a 1-to-1 function can be thought of as an m-tuple with no repeated elements.
L18 10
Second Interpretation:Number of r-combinations
In the second interpretation of bagel counting problem, order doesn’t matter.
Answer will be C (17,13) vs. P (17,13).C (17,13) measures the number of distinct
size-13 subsets in a set of size 13, as opposed to size 13 permutations. In general: C (n,r ) is defined as the cardinality of:
{unordered size-r subsets of {1,2,3, …, n}}= {r-combinations of the set {1,2,3, …, n}}
L18 11
Second Interpretation:Number of r-combinations
Let’s prove the previously mentioned formula:
C (n,r ) = n ! / ( r ! · (n - r)! )Simpler to express this with falling power:
C (n,r ) = n r / r !First check to see if know how to apply
formula:Q: How many different subsets of 2 bagels
are there in set of 4?
L18 12
Second Interpretation:Number of r-combinations
A: Subsets of 2 bagels in a set of 4.
{ , , , }
Answer = 6.Indeed C (4,2) = (4·3)/(2·1)
= 12/2 = 6
L18 13
Division Rule
Derivation of the formula will use a new counting rule:
DIVISION RULE: Suppose S is a finite set partitioned into cells of cardinality d. Then the number of cells is |S | / d.
Q: A treasure of 187 gold coins consists of bags consisting of exactly 17 coins each. How many bags are there?
L18 15
r-combinationsDerivation of Formula
The claim C (n,r ) = n r / r ! can be restated as:C (n,r ) = P (n,r ) / r !
Suggests connection between r-combinations and r-permutations: there are r ! r-permutations for each r-combination.
EG: 3-combination {1,2,5} gives rise to 3! = 6 different 3-permutations: (1,2,5),(1,5,2),(2,1,5),(2,5,1),(5,1,2),(5,2,1).
Division rule gives formula: think of each r-combo as a cell containing r ! r-permutations.
L18 16
r-combinationsBack to our bagel example. Under 2nd
interpretation, the number of ways to buy 13 different bagels from 17 types is
2380)4,17(123414151617
12345678910111213567891011121314151617
)13,17(
==⋅⋅⋅⋅⋅⋅=
⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅=
C
C
L18 17
r-combinationsPrevious C (17,13) = C (17,4) is special
case of:General formula C (n,r ) =C (n,n-r ).Proof : Just use formula, or the inherent
symmetry of Pascal’s triangle.
L18 18
String Counting ExampleEG: How many length 38 ASCII strings are
there s.t.� All characters are distinct� The characters ‘a’ ‘b’ and ‘c’ appear in
order� (and assume that |ASCII| = 128)
L18 19
String Counting ExampleMethod for computing answer:� Decide where to put (a,b,c). There are 38
spots, out of which 3 must be chosen together, therefore C (38,3) choices.
� After 1 has been chosen, 35 spots remain. So there are 125=128-3 choices for the first, 124 for the second, etc. Therefore, 12535 choices.
� Product rule applies to (1) and (2) to obtain the final answer:
C (38,3) · 12535
L18 20
AnagramsAn anagram of a string is a
rearrangement of the letters in the string.
EG, ignoring white-space and capitals an anagram on “William Gates” is:
“Will I tame gas”-also allow random anagrams such as
“liiwlegamast”Q: How many different anagrams are
there on the string “williamgates”?
L18 21
AnagramsUsing Product Rule
A: Alphabetize “williamgates” to get:“aaegiillmstw” (length = 12)
� Choose 2 spaces to put the a’s: C (12,2)� Choose 1 space of remaining for e: C (10,1)� Choose 1 of remaining 9 for g: C (9,1)� Choose 2 of remaining 8 for i: C (8,2)� Choose 2 of remaining 6 for l: C (6,2)� Choose 1 of remaining 4 for m: C (4,1)� Choose 1 of remaining 3 for s: C (3,1)� Choose 1 of remaining 2 for t: C (2,1)� Only one choice remains for w ( C(1,1) = 1 )
L18 22
AnagramsUsing Product Rule
Use product rule obtaining answer:
C (12,2)C (10,1)C (9,1)C (8,2)C (6,2)C (4,1)C (3,1) C (2,1)
= 66·10·9·28·15·4·3·2= 59,875,200
L18 23
AnagramsUsing Division Rule
Alternative formulation:The number of anagrams is gotten by taking
the total number of permutations of the letter spaces ( n ! ) and dividing out by the number of equivalent permutations gotten by permuting repeated letters:
12! / (2! · 2! · 2!) = 479,001,600 / (2·2·2)= 59,875,200
L18 24
AnagramsUsing Division Rule
In general, if there are n letters and the repetition numbers are a1, a2 , a3 , …. , akthen the number of anagrams is given by
n ! / (a1! a2 ! a3 ! … ak !)
L18 25
Cards and Poker
Analyzing the effectiveness of card-playing strategies is an important pedagogical case-study in discrete mathematics. Some students have not seen standard European playing cards so I’ll give a little intro:
L18 26
Types of CardsThe 4 Suits
Each deck of playing cards has 52 cards (not including Jokers). These 52 cards break up into 4 basic types of cards called suits :
Hearts, Diamonds, Spades, Clubs
L18 27
Types of CardsWithin a Single Suit (clubs)
Each suit consists of 13 card values or ranks:
Ace, 2, 3, 4, 5, 6, 7
8, 9, 10, jack,queen,king
L18 28
Cards and Poker
In poker a hand consists of a set of 5 cards. There are various hand configurations that have their own special names.
L18 29
Glossary of Poker Hands� Straight flush
Five cards in sequence in the same suit. A royal straight flush (A-K-Q-J-10 in same suit) is the highest non-joker poker hand possible.
� Four of a kind Four cards of the same rank.
� Full house Three of a kind and a pair. When matching full houses, the one with the higher three of a kind wins.
� Flush Five cards of the same suit.
� Straight Any five cards in sequence but not all of the same suit.
� Three of a kind Three of the same rank with two unmatched cards.
� Two pairs Two cards of one rank with two cards of a different rank with one dissimilar card. When matching pairs occurs between players, the one with the higher fifth card wins.
� One pair Any two cards of the same rank.
L18 31
Cards and PokerExamples
A: Same as the number of 5-element subsets in a set of cardinality 52. I.e. C (52,5) = 2,598,960
Q: How many different hands constitute a full house?
L18 32
Cards and PokerExamples
A: Same as pair + 3 of a different kind� Number of pairs: 13·C (4,2)
� Choose a rank: 13� Choose 2 of 4 suits: C (4,2)
� Number of 3 of a kinds: 12·C (4,3)� Choose a different rank: 12� Choose 3 of 4 suits: C (4,3)
Answer: 13·C (4,2)·12·C (4,3) = 3744
L18 33
Blackboard Exercises for 4.3
� What’s the coefficient of x 9 in the expansion of (2-x)19 ?
� How many straight hands are there in poker?
Straight Any five cards in sequence but not all of the same suit.
L18 34
Discrete ProbabilityThe probability of an event is the likelihood
that event will occur. “Probability 1” means that it must happen while probability 0 means that it cannot happen
EG: the probability of…� “Arizona Diamondbacks defeat Yankees in the 2001
World Series” is 1� “Yankees win the Superbowl” is 0
Events which may or may not occur are assigned a number between 0 and 1.
L18 35
Discrete ProbabilityConsider the following problems:� What’s the probability of tossing a coin 3
times and getting all heads or all tails?� What’s the chance of winning the lottery?� What’s the probability that a list
consisting of n distinct numbers will not be sorted?
Set cardinalities are useful.
L18 36
Discrete Probabilityand Sets/Cardinalities
EG: What’s the probability of tossing a coin 3 times and getting all heads or all tails?
Can consider set of ways of tossing coin 3 times:S = {HHH,HHT,HTH,HTT,THH,THT,TTH,TTT}
S is called a sample space. Next, consider set of ways of tossing all heads or
all tails: E = {HHH,TTT}E is called the event.Assuming all outcomes equally likely…DEF: The probability of the event E is the ratio
p (E ) = |E | / |S |EG: Our case: p (E ) = 2/8 = 0.25
L18 37
New York State Lotto
In the NY Lotto drawing, a player picks 6 numbers between 1 and 59. Later the state picks 6 numbers and a bonus number. The player wins if he/she guesses enough correct numbers.
The prize amount depends on how many numbers were guessed correctly.
L18 38
New York State LottoWinning Tickets
� Match all six numbers� Match five numbers plus bonus � Match five numbers� Match four numbers� Match three numbersWe have the tools to figure out probability of
each type of win. We can then analyze the usefulness/uselessness of playing the lotto, based on prize-money.
Q: What is the probability of winning the first prize?
L18 39
New York State LottoA: Match all six numbers.S = { 6-combinations out of 59 }E = { the winning combination }Therefore
p (E ) = |E | / |S | = 1/C (59,6) = 1 / 45,057,474 = 2.2193876203·10-8
Q: What’s the probability of winning the second prize?
L18 40
New York State LottoA: This is a little tougher. Assume that
you have sorted your lottery number picks (this is what actually happens automatically when your ticket is printed out) so your ticket looks like:
There are 6 possibilities for where the bonus number could be:
FEDCBA
FEDCBA FEDCBA FEDCBA
FEDCBA FEDCBA FEDCBA
L18 41
New York State Lotto
By symmetry, they are all equivalent to the last caseso can analyze the probability of this case occurring and use the sum rule to multiply the probability by 6 (since the event set E is the disjoint union of these cases).
Let’s analyze the probability of this case using the product rule:
FEDCBA
L18 42
New York State Lotto� Prob. of A being in 6 winners
of 59 numbers: 6/59� Prob. of B being in 5
remaining winners: 5/58� Prob. of C being in 4
remaining winners: 4/57� Prob. of D being in 3
remaining winners: 3/56� Prob. of E being in 2
remaining winners: 2/55� Prob. of F being the bonus
number in 54 no.’s left: 1/54
FEDCBA
RESULT: using product rule and simplifying we get the probability of this case being:
1/C (59,6)
L18 43
New York State LottoBringing all the cases together (so multiply by 6)
we get final answer:
6/C (59,6) = 1 / 7,509,579 = 0.0000001332
Home Exercise: Show that the probability of winning the listed prize numbers is…
• Choosing 5 of 6 winners: 0.0000070577 =C (6,1) · 6·5·4·3·2 · 53 / (59·58·57·56·55·54)
• Choosing 4 of 6 winners: 0.0004587474 =C(6,2) · 6·5·4·3 · 53·52 / (59·58·57·56·55·54)
• Choosing 3 of 6 winners: 0.0103982749 =C(6,3)· 6·5·4 · 53·52·51 / (59·58·57·56·55·54)
L18 45
Poker ProbabilitiesA: E = {full houses}. Previously:
|E | = 13·C (4,2)·12·C (4,3) = 3744S = {all hands}. Previously:
|S | = C (52,5) = 2,598,960Therefore, p (E ) = 3744 / 2,598,960
= .0014406Q: So getting a full-house in poker can
only occur once in 694 games? Seems exceedingly rare!
L18 46
Poker ProbabilitiesA: Getting a full-house in poker can only
occur once in 694 first draws! However, that’s where strategy comes in. If you get a pair, which is likely, you keep it and the second time you get dealt cards, are much more likely to get the full house…