Professional Documents
Culture Documents
SPACES
DISCRETE STRUCTURES II
DARRYL HILL
BASED ON THE TEXTBOOK:
DISCRETE STRUCTURES FOR COMPUTER SCIENCE: COUNTING,
RECURSION, AND PROBABILITY
BY MICHIEL SMID
ROSENCRANTZ AND
GUILDENSTERN ARE DEAD
GUILDENSTERN: Heads.
He keeps flipping the coin.
Heads … Heads … Heads … Heads … Heads … Heads … Heads … Heads … Heads …
Heads … Heads … Heads … Heads … Heads … Heads … Heads … Heads … Heads …
…
GUILDENSTERN: A weaker man might be moved to reexamine his faith. If for nothing
else at least in the law of probability.
He flips another coin to Rosencrantz.
ROSENCRANTZ: Heads.
𝑆: Sample space Take a fair coin, flip this coin until it comes up 𝐻 for
the first time.
Pr 𝑥 : 𝑥 ∈ 𝑆 → 0,1
Observe all coin flips are independent.
σ𝑤∈𝑆 Pr 𝑤 = 1
Sample space 𝑆 = 𝐻, 𝑇𝐻, 𝑇𝑇𝐻,𝑃 𝑇𝑇𝑇𝐻, …
Up until now, all sample spaces have = {𝑇 𝑛 𝐻: 𝑛 ≥10}
been finite sets.
Pr 𝑇 𝑛 𝐻
However, there can be sample spaces
that are infinite sets… = Pr(𝑓1 = 𝑇 ∧ 𝑓2 = 𝑇 ∧ ⋯ ∧ 𝑓𝑛 = 𝑇 ∧ 𝑓𝑛+1 = 𝐻)
S T T T H
𝑆: Sample space Pr 𝑇 𝑛 𝐻
Pr 𝑥 : 𝑥 ∈ 𝑆 → 0,1 = Pr 𝑓1 = 𝑇 ∧ 𝑓2 = 𝑇 ∧ ⋯ ∧ 𝑓𝑛 = 𝑇 ∧ 𝑓𝑛+1 = 𝐻
= Pr 𝑓1 = 𝑇 ⋅ Pr 𝑓2 = 𝑇 ⋅ … ⋅ Pr 𝑓𝑛+1 = 𝐻
σ𝑤∈𝑆 Pr 𝑤 = 1
1
𝑛+1
𝑃1
Fair coin, flip until it comes up 𝐻 =
2
S T T T H
Infinite Series:
To define it for infinity we use
Given an infinite sequence 𝑎0 , 𝑎1 , 𝑎2 , … of 𝑁
real numbers, we want to define the sum
lim 𝑎𝑛
of these numbers. 𝑁→∞
𝑛=0
𝑃1
We know if there are finite many (say 𝑁 If the limit exists, then we can write it as
numbers in the sequence), then we can
define the sum by:
𝑁 ∞
𝑁
lim 𝑎𝑛 = 𝑎𝑛
𝑁→∞
𝑛=0 𝑛=0
𝑎𝑛
𝑛=0
Infinite Series: 𝑎0 , 𝑎1 , 𝑎2 , … real numbers
Then
𝑁 ∞
∞ 𝑁
1 − 𝑥 𝑁+1
lim 𝑎𝑛 = 𝑎𝑛
𝑁→∞ 𝑥 𝑛 = lim 𝑥 𝑛 = lim
𝑛=0 𝑛=0 𝑁→∞ 𝑁→∞ 1 − 𝑥
𝑛=0 𝑛=0
𝑃1
(if the limit exists)
We can prove this using induction on 𝑁,
however, there is another way to prove
Consider a series where we define each term this.
𝑎𝑛 as:
1 − 𝑥 𝑁+1
𝑎𝑛 = 𝑥 𝑛 , 0 < 𝑥 < 1 1 + 𝑥 + 𝑥2 + 𝑥3 + ⋯ + 𝑥𝑁 =
1−𝑥
RHS = 1 − 𝑥 𝑁+1
Infinite Series: 𝑎0 , 𝑎1 , 𝑎2 , … real numbers
For 0 < 𝑥 < 1:
𝑁 ∞
lim 𝑎𝑛 = 𝑎𝑛
𝑁→∞ lim 𝑥 𝑁+1 = 0
𝑛=0 𝑛=0 𝑁→∞
𝑃1
(if the limit exists) Thus:
1 − 𝑥 𝑁+1 1
lim =
𝑁→∞ 1 − 𝑥 1−𝑥
For 0 < 𝑥 < 1:
And
∞ 𝑁 ∞
1 − 𝑥 𝑁+1 1
𝑥 𝑛 = lim 𝑥 𝑛 = lim 𝑥𝑛 =
𝑁→∞ 𝑁→∞ 1−𝑥 1−𝑥
𝑛=0 𝑛=0 𝑛=0
Infinite Series:
1
We can test this out for 𝑥 = :
2
For 0 < 𝑥 < 1:
∞ 𝑛
∞ 1 1 1 1 1
1 =1+ + + …= =2
𝑥𝑛 = 2 2 4 8 1
1−
𝑛=0
1−𝑥 𝑛=0 𝑃1 2
1 1 1 1
0 1 2 4 8 16 2
T T T H 1
= ⋅
1 1
= ⋅2=1
2 1− 1 2
2
Fair coin, flip until it comes up 𝐻 Can also think of it as:
Pr 𝑇 𝑛 𝐻 = Pr 𝑇 𝑛
⋅ Pr(𝐻), and thus
All coin flips are independent.
𝑆 = 𝐻, 𝑇𝐻, 𝑇𝑇𝐻, 𝑇𝑇𝑇𝐻, … ∞ ∞
= {𝑇 𝑛 𝐻: 𝑛 ≥ 0} Pr 𝑇 𝑛 𝐻 = Pr 𝑇 𝑛
⋅ Pr(𝐻)
𝑛=0 𝑛=0
𝑃1
For 0 < 𝑥 < 1: ∞
= Pr 𝐻 ⋅ Pr 𝑇 𝑛
∞ 𝑛=0
1
𝑥𝑛 = 𝑛
1−𝑥 1 1 ∞
𝑛=0 = ⋅
2 𝑛=0 2
T T T H 1 1 1
= ⋅ = ⋅2=1
2 1− 1 2
2
Fair coin, flip until it comes up 𝐻 We may also think of it like this:
=1
T T T H
For 0 < 𝑥 < 1: Who do we think should win this game?
∞ (This does not seem very fair.)
1
𝑥𝑛 =
1−𝑥
𝑛=0
The sample space 𝑆 = {T n H: n ≥ 0}
Consider a game: fair coin and players 𝑃1
𝑃1
and 𝑃2 take turns flipping the coin. (First time heads is flipped the game ends.)
The first player to flip heads wins.
𝑃1 =T 𝑃2 =T 𝑃1 =T 𝑃2 = H
Every element of 𝑆 where 𝑛 is an even number.
For 0 < 𝑥 < 1: Let event 𝐴 = 𝑃1 wins.
∞ 𝐴 = {𝐻, 𝑇𝑇𝐻, 𝑇𝑇𝑇𝑇𝐻, 𝑇𝑇𝑇𝑇𝑇𝑇𝐻, … }
1
𝑥𝑛 = 𝐴 = {𝑇 2𝑚 𝐻: 𝑚 ≥ 0}
1−𝑥
𝑛=0
Pr(𝑇 2𝑚 𝐻)
𝑃1 =T 𝑃2 =T 𝑃1 =T 𝑃2 = H
𝑚=0
Each coin flip is independent…
For 0 < 𝑥 < 1: The product of each outcome is the product of
∞ the probabilities of the coin flips.
𝑛
1
𝑥 =
1−𝑥
𝑛=0 ∞ ∞
= Pr 𝑇 ⋅ Pr 𝑇 ⋅ … Pr(𝑇) ⋅ Pr(𝐻)
The sample space 𝑆 = {T n H: n ≥ 0}
𝑚=0
∞ ∞ ∞ 2𝑚+1
Pr(𝑇 2𝑚 𝐻) 2𝑚
1
= Pr(𝑇) ⋅ Pr(𝐻) =
𝑚=0 2
𝑚=0 𝑚=0
For 0 < 𝑥 < 1: The product of each outcome is the product of
∞ the probabilities of the coin flips.
𝑛
1
𝑥 =
1−𝑥
𝑛=0 ∞ ∞ 2𝑚+1
1
Consider a game: fair coin and players 𝑃1 Pr(𝑇 𝐻) = 𝑃1
2𝑚
2
𝑚=0 𝑚=0
and 𝑃2 take turns flipping the coin.
The first player to flip heads wins. ∞ 2𝑚 ∞ 𝑚
1 1 1 1 1
= ⋅ = ⋅
The sample space 𝑆 = {T n H: n ≥ 0} 2 2 2 2 2
𝑚=0 𝑚=0
∞ ∞ 𝑚
Pr(𝑇 2𝑚 𝐻) 1 1 1 1 1 4 2
= = ⋅ = ⋅ =
𝑚=0 2 4
𝑚=0
2 1−1 2 3 3
4
2
For 0 < 𝑥 < 1: Pr 𝑃𝑙𝑎𝑦𝑒𝑟 1 𝑤𝑖𝑛𝑠 =
3
∞ 1
1 Pr 𝑃𝑙𝑎𝑦𝑒𝑟 2 𝑤𝑖𝑛𝑠 =
𝑛 3
𝑥 =
1−𝑥
𝑛=0
∞ ∞ 2𝑚+2
Consider a game: fair coin and players 𝑃1 Pr(𝑇 2𝑚+1 𝑃
𝐻) = 1
1
2
𝑚=0 𝑚=0
and 𝑃2 take turns flipping the coin.
The first player to flip heads wins. ∞ 2𝑚 2 ∞ 𝑚
1 1 1 1 1
The sample space 𝑆 = {T n H: n ≥ 0} = ⋅
2 2 4 2 2
𝑚=0 𝑚=0
∞
∞ 𝑚
Pr(𝑇 2𝑚 𝐻) 1 1 1 1 1 4 1
= = ⋅ = ⋅ =
𝑚=0 4 4 4 1− 1 4 3 3
𝑚=0 4
What do these outcomes of 𝑆 look like?
New game: fair coin and players 𝑃1
𝑇𝑇𝑇𝑯 𝑇𝑇𝑯 or
and 𝑃2 take turns flipping the coin.
𝑯 𝑇𝑇𝑇𝑯 or
The second player to flip heads wins.
𝑇𝑇𝑇𝑇𝑇𝑇𝑯 𝑇𝑇𝑇𝑇𝑇𝑇𝑯 or
𝐴 = 𝑃1 wins
𝑯𝑯 𝑃1
What is Pr(𝐴)?
Also, who has a higher chance of
The sample space 𝑆 = {T n 𝐇T m 𝐇, : n ≥ 0, 𝑚 ≥ 0}
winning, 𝑃1 or 𝑃2 ?
Pr 𝐴1 = Pr(T 2j+1 HT 2k H)
𝐴1 = 𝑃1 wins and 𝑛 is odd
𝑗=0 𝑘=0
𝐴2 = 𝑃1 wins and 𝑚 is odd
∞ ∞ 2𝑗+2𝑘+3
1
=
2
𝑗=0 𝑘=0
New game: fair coin and players 𝑃1 ∞ ∞ 2𝑗+2𝑘+3
1
Pr 𝐴1 =
and 𝑃2 take turns flipping the coin. 2
𝑗=0 𝑘=0
The second player to flip heads wins.
∞ 2𝑗+3 ∞ 2𝑘
𝐴 = 𝑃1 wins
=
1
𝑃1
1
What is Pr(𝐴)? 2 2
𝑗=0 𝑘=0
𝑆 = {T n HT m H, : n ≥ 0, 𝑚 ≥ 0}
3 ∞ 2𝑗 ∞ 2𝑘
𝐴1 = 𝑃1 wins and 𝑛 is odd 1 1 1
=
2 2 2
𝐴2 = 𝑃1 wins and 𝑚 is odd 𝑗=0 𝑘=0
∞ 𝑗 ∞ 𝑘
1 1 1
=
8 4 4
𝑗=0 𝑘=0
New game: fair coin and players 𝑃1 ∞ 𝑗 ∞ 𝑘
1 1 1
Pr 𝐴1 =
and 𝑃2 take turns flipping the coin. 8 4 4
𝑗=0 𝑘=0
The second player to flip heads wins.
∞ 𝑗
𝐴 = 𝑃1 wins 1
=
1
⋅
𝑃11
What is Pr(𝐴)? 8 4 1
𝑗=0 1−
4
𝑆 = {T n HT m H, : n ≥ 0, 𝑚 ≥ 0}
𝐴1 = 𝑃1 wins and 𝑛 is odd 1 1 1
= ⋅ ⋅
8 1− 1−1
1
𝐴2 = 𝑃1 wins and 𝑚 is odd 4 4
∞ 1 4 4 16 2
1 = ⋅ ⋅ = =
𝑥𝑛 = ,0 < 𝑥 < 1 8 3 3 72 9
1−𝑥
𝑛=0
To determine 𝐴2 we can rewrite 𝑚 = 2𝑘 + 1 since
New game: fair coin and players 𝑃1
it is odd and 𝑛 = 2𝑗 since it is even. Thus:
and 𝑃2 take turns flipping the coin.
The second player to flip heads wins. ∞ ∞
Pr 𝐴2 = Pr(T 2j HT 2k+1 H)
𝐴 = 𝑃1 wins
𝑗=0 𝑘=0 𝑃1
What is Pr(𝐴)?
∞ ∞ 2𝑗+2𝑘+3
𝑆= {T n HT m H, : n ≥ 0, 𝑚 ≥ 0} 1
=
𝐴1 = 𝑃1 wins and 𝑛 is odd 2
𝑗=0 𝑘=0
𝐴2 = 𝑃1 wins and 𝑚 is odd 2
=
9
Pr 𝐴 = Pr 𝐴1 + Pr 𝐴2
New game: fair coin and players 𝑃1
2 2
and 𝑃2 take turns flipping the coin. = +
9 9
The second player to flip heads wins.
4
=
𝐴 = 𝑃1 wins 9 𝑃1
What is Pr(𝐴)?
𝑆 = {T n HT m H, : n ≥ 0, 𝑚 ≥ 0} 4
Thus the probability that 𝑃1 wins is now , and thus
9
𝐴1 = 𝑃1 wins and 𝑛 is odd
5
𝐴2 = 𝑃1 wins and 𝑚 is odd the probability that 𝑃2 wins is . So the odds have
9
Pr 𝐵12 = Pr 𝐵21 =
3
1 𝑃1second round
𝑃1 wins first round and 𝑃2 wins
3
Same game: fair coin and players 𝑃1 and 𝑃2
𝑃2 wins first round and 𝑃1 wins second round
take turns flipping the coin.
𝑃2 wins first round and 𝑃2 wins second round
The second player to flip heads wins.
𝐴 is the event where 𝑃1 wins.
𝐴 = 𝑃1 wins
Thus 𝐴 =
We will look at an easier way to determine
(𝑃1 wins first round and 𝑃1 wins second round) or
Pr 𝐴 .
(𝑃2 wins first round and 𝑃1 wins second round).
Can split 𝐴 into 2 events based on the or:
Fair coin, players 𝑃1 and 𝑃2 take turns
flipping the coin. For 𝑖, 𝑗 ∈ {1,2}:
Events: 𝐵𝑖𝑗 = 𝑃𝑖 starts, 𝑃𝑗 wins Let 𝐴1 = 𝑃1 wins first round and 𝑃1 wins second
2
Pr 𝐵11 = Pr 𝐵22 =
3
1
round
Pr 𝐵12 = Pr 𝐵21 =
3 𝑃1 𝑃1 wins second
Let 𝐴2 = 𝑃2 wins first round and
Same game: fair coin and players 𝑃1 and 𝑃2
round
take turns flipping the coin.
𝐴 ↔ 𝐴1 or 𝐴2
The second player to flip heads wins.
𝐴1 and 𝐴2 are disjoint events, thus we can use the
𝐴 = 𝑃1 wins
sum rule.
We will look at an easier way to determine
Pr 𝐴 = Pr 𝐴1 + Pr 𝐴2
Pr 𝐴 .
Fair coin, players 𝑃1 and 𝑃2 take We can rewrite 𝐴1 and 𝐴2 in terms of 𝐵𝑖𝑗 .
turns flipping the coin. For 𝑖, 𝑗 ∈ 𝐴1 = 𝑃1 wins first and 𝑃1 wins second
{1,2}:
Events: 𝐵𝑖𝑗 = 𝑃𝑖 starts, 𝑃𝑗 wins
2
Pr 𝐵11 = Pr 𝐵22 = 𝐴1 ↔ 𝑃1 starts the 1st round, and
This is
Pr 𝐵12 = Pr 𝐵21 =
3
1
𝑃1 wins the 1st
𝑃
round, and1 event 𝐵11 .
3
Same game: fair coin and players 𝑃1 and 𝑃2
𝑃2 starts the 2nd round, and This is
take turns flipping the coin.
𝑃1 wins the 1st round. event 𝐵21 .
The second player to flip heads wins.
𝐴 = 𝑃1 wins
We will look at an easier way to determine Thus:
We will focus on one scenario: The event that we win corresponds to 0 or more rolls
that are neither 7 or 9, followed by a 9. Thus
On your "come-out" roll you roll a 9 𝑃1
on two dice.
∞
Now you must keep rolling 2 dice Pr 𝑊𝑖𝑛 = Pr 𝑅7 ∪ 𝑅9 𝑖 ⋅ Pr 𝑅9
until you either roll 9 again, in which 𝑖=0
case you win, or you roll a 7, in which
case the house wins (you lose). ∞ 𝑖
13 1
= ⋅
What is the probability that you win? 18 9
𝑖=0
What is the probability that you lose?
13 1 1
Craps is a game where you roll two Pr 𝑅7 ∪ 𝑅9 =
18
, Pr 𝑅7 = ,
6
Pr 𝑅9 =
9
dice and bet on the outcome.
∞ 𝑖
We will focus on one scenario: 13 1
Pr 𝑊𝑖𝑛 = ⋅
18 9
On your "come-out" roll you roll a 9 𝑖=0
𝑃1
on two dice.
∞ 𝑖
1 13
Now you must keep rolling 2 dice = ⋅
9 18
until you either roll 9 again, in which 𝑖=0
case you win, or you roll a 7, in which
case the house wins (you lose). 1 1
= ⋅
9 1 − 13
What is the probability that you win? 18
What is the probability that you lose? 1 18 2
= ⋅ =
9 5 5
13 1 1
Craps is a game where you roll two Pr 𝑅7 ∪ 𝑅9 =
18
, Pr 𝑅7 = ,
6
Pr 𝑅9 =
9
dice and bet on the outcome.
∞
We will focus on one scenario:
Pr 𝐿𝑜𝑠𝑒 = Pr 𝑅7 ∪ 𝑅9 𝑖 ⋅ Pr 𝑅7
On your "come-out" roll you roll a 9 𝑖=0
𝑃1
on two dice.
∞ 𝑖
13 1
Now you must keep rolling 2 dice = ⋅
18 6
until you either roll 9 again, in which 𝑖=0
case you win, or you roll a 7, in which
case the house wins (you lose). ∞ 𝑖
1 13 1 1 1 18 3
= ⋅ = ⋅ = ⋅ =
6 18 6 1 − 13 6 5 5
What is the probability that you win? 𝑖=0 18
What is the probability that you lose?