View
4
Download
0
Category
Preview:
Citation preview
Probability
Will MonroeSummer 2017
with materials byMehran Sahamiand Chris Piech
June 30, 2017
Today we will make history
Logistics: Office hours
Review: Permutations
The number of ways of orderingn distinguishable objects.
n ! =1⋅2⋅3⋅...⋅n=∏i=1
n
i
Review: Combinations
The number of unique subsets of size k from a larger set of size n. (objects are distinguishable, unordered)
(nk ) =n !
k !(n−k)!
choose k
n
Review: Bucketing
The number of ways of assigning n distinguishable objects to a fixedset of k buckets or labels.
kn
k buckets
n objects
Divider method
The number of ways of assigning n indistinguishable objects to a fixedset of k buckets or labels.
(n+(k−1)
n )
k buckets
n objects
(k - 1 dividers)
A grid of ways of counting
kn(nk )n !
n !k1! k2!…km !
(n+(k−1)
n )1 1
Creativity!– Split into cases– Use inclusion/exclusion– Reframe the problem
Ordering Subsets Bucketing
Alldistinct
Someindistinct
Allindistinct
Sample space
S = the set of all possible outcomes
Coin flip
Two coin flips
Roll of 6-sided die
# emails in day
Netflix hours in day
S = {Heads, Tails}
S = {(H, H), (H, T), (T, H), (T, T)}
S = {1, 2, 3, 4, 5, 6}
S = (non-neg. integers)ℕ
S = [0, 24] (interval, inclusive)
Events
E = some subset of S (E ⊆ S)
Coin flip is heads
≥ 1 head on 2 flips
Roll of die ≤ 3
# emails in day ≤ 20
“Wasted day”
E = {Heads}
E = {(H, H), (H, T), (T, H)}
E = {1, 2, 3}
E = {x | x ∈ , x ≤ 20}ℕ
E = [5, 24]
(Ross uses to mean )⊂ ⊆
Set operations
E ∪ F = {1, 2, 3}
E = {1, 2}
F ={2, 3}
S = {1, 2, 3, 4, 5, 6}
Union: outcomes that are in E or F
Set operations
EF = E ∩ F = {2}
E = {1, 2}
F ={2, 3}
S = {1, 2, 3, 4, 5, 6}
Intersection: outcomes that are in E and F
Set operations
Ec = {3, 4, 5, 6}
E = {1, 2}
F ={2, 3}
S = {1, 2, 3, 4, 5, 6}
Complement: outcomes that are not in E
A profound truth
https://medium.com/@timanglade/how-hbos-silicon-valley-built-not-hotdog-with-mobile-tensorflow-keras-react-native-ef03260747f3
A profound truth
Everything in the world is either
a hot dog
or
not a hot dog.
(E ∪ Ec = S)
https://medium.com/@timanglade/how-hbos-silicon-valley-built-not-hotdog-with-mobile-tensorflow-keras-react-native-ef03260747f3
Quiz question
https://b.socrative.com/login/student/
Room: CS109SUMMER17
Quiz questionWhich is the correct picture for EcFc (= Ec ∩ Fc)?
E F
S
E F
S
E F
S
E F
S
E F
S
A
B
C
D
E
Quiz question
E F
S
C
Which is the correct picture for EcFc (= Ec ∩ Fc)?
Quiz questionWhich is the correct picture for Ec ∪ Fc?
E F
S
E F
S
E F
S
E F
S
E F
S
A
B
C
D
E
Quiz questionWhich is the correct picture for Ec ∪ Fc?
E F
S
D
De Morgan's Laws“distributive laws” for set complement
E F
S
(E ∪ F)c = Ec ∩ Fc (E ∩ F)c = Ec ∪ Fc
E F
S
(⋃i Ei)c=⋂
i(Ei
c ) (⋂i Ei )c=⋃
i(Ei
c )
What is a probability?
A number between 0 and 1to which we ascribe meaning
Sources of probability
Experiment
Expert opinion Analytical solution
Datasets
Meaning of probability
A quantification of ignorance
image: Frank Derks
P(E)=limn→∞
# (E)
n
What is a probability?
Axioms of probability
0≤P(E)≤1
P(S)=1
P(E∪F)=P(E)+P(F)If E∩F=∅ , then
(1)
(2)
(3)
(Sum rule, but with probabilities!)
Corollaries
P(Ec)=1−P(E)
P(E∪F)=P(E)+P(F)−P(EF)
If E⊆F , then P(E)≤P(F)
(Principle of inclusion/exclusion, but with probabilities!)
Principle of Inclusion/Exclusion
The total number of elements in two sets is the sum of the number of elements of each set,minus the number of elements in both sets.
|A∪B|=|A|+|B|−|A∩B|
3 4
3+4-1 = 6
Inclusion/exclusion withmore than two sets
|E∪F∪G|=
E
F G
Inclusion/exclusion withmore than two sets
|E∪F∪G|=|E|
E
F G
1
1
11
Inclusion/exclusion withmore than two sets
|E∪F∪G|=|E|+|F|
E
F G
1
2
12
11
Inclusion/exclusion withmore than two sets
|E∪F∪G|=|E|+|F|+|G|
E
F G
1
3
22
12 1
Inclusion/exclusion withmore than two sets
|E∪F∪G|=|E|+|F|+|G|
E
F G
1
2
21
12 1
−|EF|
Inclusion/exclusion withmore than two sets
|E∪F∪G|=|E|+|F|+|G|
E
F G
1
1
11
12 1
−|EF|−|EG|
Inclusion/exclusion withmore than two sets
|E∪F∪G|=|E|+|F|+|G|
E
F G
1
0
11
11 1
−|EF|−|EG|−|FG|
Inclusion/exclusion withmore than two sets
|E∪F∪G|=|E|+|F|+|G|
E
F G
1
1
11
11 1
−|EF|−|EG|−|FG|
+|EFG|
Inclusion/exclusion withmore than two sets
|⋃i=1
n
Ei|=∑r=1
n
(−1)(r+1) ∑
i1<⋯< ir
|⋂j=1
r
Ei j|
size ofthe union
sum oversubsetsizes
add orsubtract
(based on size)
size ofintersections
sum overall subsetsof that size
Inclusion/exclusion withmore than two sets
P(⋃i=1
n
Ei)=∑r=1
n
(−1)(r+1) ∑
i1<⋯< ir
P(⋂j=1
r
Ei j)
prob. ofOR
sum oversubsetsizes
add orsubtract
(based on size)
prob. ofAND
sum overall subsetsof that size
Inclusion/exclusion withmore than two sets
P(E∪F∪G)=P(E)+P(F)+P(G)
E
F G
1
1
11
11 1
−P(EF)−P(EG)−P(FG)
+P(EFG)
Break time!
Equally likely outcomes
Coin flip
Two coin flips
Roll of 6-sided die
S = {Heads, Tails}
S = {(H, H), (H, T), (T, H), (T, T)}
S = {1, 2, 3, 4, 5, 6}
P(Each outcome)=1|S|
P(E)=|E|
|S|(counting!)
Rolling two dice
P(D1+D2=7)=?D1 D2
How do I get started?
For word problems involving probability,start by defining events!
Rolling two dice
P(D1+D2=7)=?D1 D2
E: {all outcomes such that the sum of the two dice is 7}
Rolling two dice
P(D1+D2=7)=6
36=
16D1 D2
S = {(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6),
S = {(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6),
S = {(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6),
S = {(4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6),
S = {(5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6),
S = {(6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)}
|S|=36
|E|=6
Rolling two (indistinguishable) dice?
P(D1+D2=7)=3
21=
17
?D1 D2
S = {(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6),
S = {(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6),
S = {(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6),
S = {(4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6),
S = {(5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6),
S = {(6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)}
|S|=21
|E|=3
[check your assumptions]
Getting rid of ORs
Finding the probability of an OR of events can be nasty. Try using De Morgan's laws to turn it into an AND!
P(A∪B∪⋯∪Z )=1−P(Ac Bc⋯Zc
)
E F
S
Running into a friend
image: torbakhopper / scott richard
21,000 people at StanfordYou're friends with 250
Go to an event with 70 other(equally-likely) Stanforders
What's P(at least one friend among the 70)?
S: {all subsets of size 70 of 21,000 students}
E: {subsets of size 70 with at least one friend}
|S|=(21,00070 )
|E|=???
Running into a friend
image: torbakhopper / scott richard
21,000 people at StanfordYou're friends with 250
Go to an event with 70 other(equally-likely) Stanforders
What's P(at least one friend among the 70)?
S: {all subsets of size 70 of 21,000 students}
E: {subsets of size 70 with at least one friend}Ec: {subsets of size 70 with no friends}|S|=(21,000
70 )
|EC|=(21,000−250
70 ) P(E)=1−P(EC)=1−
(20,75070 )
(21,00070 )
≈0.5512
Running into a friend
https://cs109.stanford.edu/demos/serendipity.html
serendipity [ˌse.ɹənˈdɪ.pɨ.ɾi] n the faculty or phenomenon of finding valuable or agreeable things not sought for
Merriam-Webster
Getting rid of ORs
Finding the probability of an OR of events can be nasty. Try using De Morgan's laws to turn it into an AND!
P(A∪B∪⋯∪Z )=1−P(Ac Bc⋯Zc
)
E F
S
Defective chips
n
k
|S|=(nk)
|E|=1⋅(n−1k−1)
S: {all subsets of size k from n chips}
E: {all outcomes such that the defective chip is chosen}
Defective chips
n
k
|S|=(nk)
|E|=1⋅(n−1k−1)
P(E)=(n−1k−1)
(nk)=
(n−1)!(k−1)!(n−k )!
n !k !(n−k)!
=(n−1)! k !n!(k−1)!
=(n−1)!⋅k⋅(k−1)!n⋅(n−1)!(k−1)!
=kn
Poker straight
(Standard deck:)52 cards = 13 ranks × 4 suits
“Straight”: 5 consecutive ranks(suits can be different)
S: {all possible hands}
E: {all hands that are straights}
|S|=(525 )
|E|=10⋅45
startingrank
suit ofeach card
image: Guts Gaming (www.guts.com/en)
Poker straight
(Standard deck:)52 cards = 13 ranks × 4 suits
“Straight”: 5 consecutive ranks(suits can be different)
S: {all possible hands}
E: {all hands that are straights}
|S|=(525 )
|E|=10⋅45
P(E)=10⋅45
(525 )
≈0.00394
image: Guts Gaming (www.guts.com/en)
Birthdays
n people in a room.What is the probability none share the same birthday?
S: {all ways of giving all n people each a birthday}
E: {all ways of giving all n people different birthdays}
|S|=365n
|E|=365⋅364⋅…⋅(365−n+1)=365 !
(365−n)!=(365
n )⋅n !
P(E)=(365
n )⋅n !
365n
n = 23: P(E) < 1/2n = 75: P(E) < 1/3,000n = 100: P(E) < 1/3,000,000n = 150: P(E) < 1/3,000,000,000,000,000
Flipping cards● Shuffle deck.
● Reveal cards from the top until we get an Ace. Put Ace aside.
● What is P(next card is the Ace of Spades)?
● P(next card is the 2 of Clubs)?
https://bit.ly/1a2ki4G → https://b.socrative.com/login/student/Room: CS109SUMMER17
A) P(Ace of Spades) > P(2 of Clubs)
B) P(Ace of Spades) = P(2 of Clubs)
C) P(Ace of Spades) < P(2 of Clubs)
Flipping cards● Shuffle deck.
● Reveal cards from the top until we get an Ace. Put Ace aside.
● What is P(next card is the Ace of Spades)?
● P(next card is the 2 of Clubs)?
S: {all orderings of the deck}
E: {all orderings for which Ace of Spadescomes immediately after first Ace}
|S|=52!
|E|=51!⋅1P(E)=
51!52!
=152
Flipping cards● Shuffle deck.
● Reveal cards from the top until we get an Ace. Put Ace aside.
● What is P(next card is the Ace of Spades)?
● P(next card is the 2 of Clubs)?
S: {all orderings of the deck}
E: {all orderings for which 2 of Clubscomes immediately after first Ace}
|S|=52!
|E|=51!⋅1P(E)=
51!52!
=152
Flipping cards● Shuffle deck.
● Reveal cards from the top until we get an Ace. Put Ace aside.
● What is P(next card is the Ace of Spades)?
● P(next card is the 2 of Clubs)?
B) P(Ace of Spades) = P(2 of Clubs)
(We just made history)
Recommended