Probability Will Monroe Summer 207 with materials by Mehran Sahami and Chris Piech June 30, 207
Today we will make history
Logistics: Office hours
Review: Permutations The number of ways of ordering n distinguishable objects. n n! = 2 3... n= i i=
Review: Combinations The number of unique subsets of size k from a larger set of size n. (objects are distinguishable, unordered) n k () n! = k!(n k )! choose k n
Review: Bucketing The number of ways of assigning n distinguishable objects to a fixed set of k buckets or labels. k n n objects k buckets
Divider method The number of ways of assigning n indistinguishable objects to a fixed set of k buckets or labels. ( n+(k ) n ) n objects k buckets (k - dividers)
A grid of ways of counting All distinct Some indistinct All indistinct Ordering Subsets n! n k () k n Creativity! Split into cases Use inclusion/exclusion Reframe the problem n! k! k 2! k m! Bucketing ( n+(k ) n )
Sample space S = the set of all possible outcomes Coin flip S = {Heads, Tails} Two coin flips S = {(H, H), (H, T), (T, H), (T, T)} Roll of 6-sided die S = {, 2, 3, 4, 5, 6} # emails in day S = ℕ (non-neg. integers) Netflix hours in day S = [0, 24] (interval, inclusive)
Events E = some subset of S (E S) Coin flip is heads E = {Heads} head on 2 flips E = {(H, H), (H, T), (T, H)} Roll of die 3 E = {, 2, 3} # emails in day 20 E = {x x ℕ, x 20} Wasted day E = [5, 24] (Ross uses to mean )
Set operations Union: outcomes that are in E or F S = {, 2, 3, 4, 5, 6} E= {, 2} F= {2, 3} E F = {, 2, 3}
Set operations Intersection: outcomes that are in E and F S = {, 2, 3, 4, 5, 6} E= {, 2} F= {2, 3} EF = E F = {2}
Set operations Complement: outcomes that are not in E S = {, 2, 3, 4, 5, 6} E= {, 2} F= {2, 3} Ec = {3, 4, 5, 6}
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: CS09SUMMER7
Quiz question Which is the correct picture for EcFc (= Ec Fc)? S A S E F D S B F E F S E F E F S C E E
Quiz question Which is the correct picture for EcFc (= Ec Fc)? S C E F
Quiz question Which is the correct picture for Ec Fc? S A S E F D S B F E F S E F E F S C E E
Quiz question Which is the correct picture for Ec Fc? S D E F
De Morgan's Laws distributive laws for set complement (E F)c = Ec Fc (E F)c = Ec Fc S S F E c F E Ei = ( Ei ) (i ) i c c Ei = ( Ei ) (i ) i c
What is a probability? A number between 0 and to which we ascribe meaning
Sources of probability Experiment Datasets Expert opinion Analytical solution
Meaning of probability A quantification of ignorance image: Frank Derks
What is a probability? # ( E) P( E)=lim n n
Axioms of probability () (2) (3) 0 P( E) P(S)= If E F=, then P( E F)=P( E)+ P( F) (Sum rule, but with probabilities!)
Corollaries c P( E )= P( E) If E F, then P( E) P( F) P( E F)=P( E)+ P( F) P( EF) (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- = 6
Inclusion/exclusion with more than two sets E F G = E F G
Inclusion/exclusion with more than two sets E F G = E E F G
Inclusion/exclusion with more than two sets E F G = E + F E 2 2 F G
Inclusion/exclusion with more than two sets E F G = E + F + G E 2 2 3 F 2 G
Inclusion/exclusion with more than two sets E F G = E + F + G EF E 2 2 F 2 G
Inclusion/exclusion with more than two sets E F G = E + F + G EF EG E F 2 G
Inclusion/exclusion with more than two sets E F G = E + F + G EF EG FG E 0 F G
Inclusion/exclusion with more than two sets E F G = E + F + G EF EG FG E + EFG F G
Inclusion/exclusion with more than two sets size of the union n add or subtract (based on size) n size of intersections r Ei = ( ) i= i < <i r sum over subset sizes sum over all subsets of that size (r +) r= Ei j= j
Inclusion/exclusion with more than two sets prob. of OR n P ( ) add or subtract (based on size) prob. of AND n Ei = ( ) i= r (r +) r= sum over subset sizes i < <i r P ( ) sum over all subsets of that size Ei j= j
Inclusion/exclusion with more than two sets P( E F G)=P( E)+ P( F)+ P(G) P( EF) P( EG) P(FG) E + P( EFG) F G
Break time!
Equally likely outcomes Coin flip S = {Heads, Tails} Two coin flips S = {(H, H), (H, T), (T, H), (T, T)} Roll of 6-sided die S = {, 2, 3, 4, 5, 6} P(Each outcome)= S E P( E)= S (counting!)
Rolling two dice D D2 P( D + D 2=7)=?
How do I get started? For word problems involving probability, start by defining events!
Rolling two dice D D2 P( D + D 2=7)=? E: {all outcomes such that the sum of the two dice is 7}
Rolling two dice D D2 6 P( D + D 2=7)= = 36 6 S = {(, ), (, 2), (, 3), (, 4), (, 5), (, 6), S = {(2, ), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), E =6 S =36 S = {(3, ), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), S = {(4, ), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), S = {(5, ), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), S = {(6, ), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)}
Rolling two (indistinguishable) dice? D D2 3 sumptions] P( D + D 2=7)= as =? r u o y k c e 2 7 [ch S = {(, ), (, 2), (, 3), (, 4), (, 5), (, 6), S = {(2, ), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), E =3 S =2 S = {(3, ), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), S = {(4, ), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), S = {(5, ), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), S = {(6, ), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)}
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! c c c P( A B Z )= P( A B Z ) S E F
Running into a friend 2,000 people at Stanford You're friends with 250 Go to an event with 70 other (equally-likely) Stanforders What's P(at least one friend among the 70)? E =??? 2,000 S = 70 ( E: {subsets of size 70 with at least one friend} ) S: {all subsets of size 70 of 2,000 students} image: torbakhopper / scott richard
Running into a friend 2,000 people at Stanford You're friends with 250 Go to an event with 70 other (equally-likely) Stanforders What's P(at least one friend among the 70)? 20,750 70 C C E = 2,000 250 P( E)= P( E )= 2,000 0.552 70 70 E: {subsets of size 70 with at least one friend} 2,000 S = Ec: {subsets of size 70 with no friends} 70 S: {all subsets of size 70 of 2,000 students} ( ( ) ( ( ) ) ) image: torbakhopper / scott richard
Running into a friend https://cs09.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! c c c P( A B Z )= P( A B Z ) S E F
Defective chips k E = n k ( ) n S = (k ) n E: {all outcomes such that the defective chip is chosen} S: {all subsets of size k from n chips}
Defective chips k E = n k ( ) n S = (k ) n n k ( ) P( E)= n (k ) (n )! (k )!(n k )! (n )! k! (n )! k (k )! k = = = = n! n!(k )! n (n )!(k )! n k!(n k)!
Poker straight (Standard deck:) 52 cards = 3 ranks 4 suits Straight : 5 consecutive ranks (suits can be different) starting rank E: {all hands that are straights} E =0 4 52 S = 5 ( ) S: {all possible hands} 5 suit of each card image: Guts Gaming (www.guts.com/en)
Poker straight (Standard deck:) 52 cards = 3 ranks 4 suits Straight : 5 consecutive ranks (suits can be different) E: {all hands that are straights} S: {all possible hands} E =0 4 52 S = 5 ( ) 5 5 0 4 P ( E)= 0.00394 52 5 ( ) image: Guts Gaming (www.guts.com/en)
Birthdays n people in a room. What is the probability none share the same birthday? E: {all ways of giving all n people different birthdays} S: {all ways of giving all n people each a birthday} 365! 365 E =365 364 (365 n+)= = n! (365 n)! n n S =365 ( ) 365 n! n ( ) P( E)= 365 n n = 23: P(E) < /2 n = 75: P(E) < /3,000 n = 00: P(E) < /3,000,000 n = 50: P(E) < /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)? 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) https://bit.ly/a2ki4g https://b.socrative.com/login/student/ Room: CS09SUMMER7
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)? E: {all orderings for which Ace of Spades comes immediately after first Ace} S: {all orderings of the deck} E =5! S =52! 5! P ( E)= = 52! 52
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)? E: {all orderings for which 2 of Clubs comes immediately after first Ace} S: {all orderings of the deck} E =5! S =52! 5! P ( E)= = 52! 52
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)