count the object using the product n 1 n 2 n 3 n k ee 90
play

= Count the object using the product n 1 n 2 n 3 . . . n k EE - PowerPoint PPT Presentation

Goals: Probability CS 70 Tips The probability section in CS 70 usually means: I Lets you quantify uncertainty I One big topic , rather than many small topics I Concretely: has applications everywhere! I Try your best to stay up to date ; use


  1. ⇐ Goals: Probability CS 70 Tips The probability section in CS 70 usually means: I Lets you quantify uncertainty I One big topic , rather than many small topics I Concretely: has applications everywhere! I Try your best to stay up to date ; use OH! Counting, Part I I Important to be comfortable with the basics I Hopefully: learn techniques for reasoning about randomness and making better decisions logically I Fewer “proofs,” more computations CS 70, Summer 2019 I Emphasis on applying tools and problem solving I Hopefully: provides a new perspective on the world I Lectures will be example-driven Lecture 13, 7/16/19 I Practice, practice, practice! 1 / 29 2 / 29 3 / 29 A Familiar Question Choices, Choices, Choices... The First Rule of Counting: Products How many bit (0 or 1) strings are there of length 3? A lunch special lets you choose one appetizer, one entre´ e, and If the object you are counting: one drink. There are 6 appetizers, 3 entre´ es, and 5 drinks. 3 choices I Comes from making k choices How many di ff erent meals could you possibly get? I Has n 1 options for the first choice -¥ ¥ tf Drink App Ent I Has n 2 options for second, regardless of the first bit I Has n 3 options for the third, regardless of the first two I ...and so on, until the k -th choice ¥÷ = ⇒ Count the object using the product n 1 × n 2 × n 3 × . . . × n k EE . ⑧ 90 4 / 29 5 / 29 6 / 29

  2. ⇒ Anagramming I Counting Functions Counting Polynomials ' in : " Exactly How many strings can we make by rearranging “CS70”? How many functions are there from { 1 , . . . , n } to { 1 , . . . , m } ? How many degree d polynomials are there modulo p ? ÷ 4×3×2×1=24 ' - Dpd Pia '¥ =p ⇐ ix. character T : - - - . . f ( N ) # 4 . . . # 2 # 3 # ÷ ④ = MN - 17cm -27 2-1 non = - - - O How many strings can we make by rearranging “ILOVECS70” if Same setup, but m ≥ n . How many injective functions are there? If d ≤ p , how many have no repeating coe ffi cients? . . . the numbers “70” must appear together in that order? pretend 't 's Exercise . " ¥ ' m 1 letter . -8×-71 I -8 ! characters : - - - - - - ND ! ( M 7 / 29 8 / 29 9 / 29 When Order Doesn’t Matter: Space Team I When Order Doesn’t Matter: Poker I The Second Rule of Counting: Repetitions Among its 10 trainees, NASA wants to choose 3 to go to the In poker, each player is dealt 5 cards. A standard deck (no jokers) Say we use the First Rule–we make k choices. lot O moon. How many ways can they do this? has 52 cards. How many di ff erent hands could you get? I Let A be the set of ordered objects. = 7 ! 8=720 I Let B be the set of unordered objects. × 9 10 x 48=51 ¥3 people ¥ 52 51 It SO 49 If there is an “ m -to- 1 ” function from A to B : cards 47 ! - - - - - BAC } = ⇒ Count A and divide by m to get | B | . ABC ¥93 7261=120 ACB ! se !?¥}s - repetitions 6 retorting offs ,z , 47 ! 5 ! Yt EEE =3 ! - - - CBA 10 / 29 11 / 29 12 / 29

  3. ⇒ ⇒ Anagramming II Binomial Coe ffi cients Binomial Coe ffi cients How many strings can we make by rearranging “APPLE”? How many ways can we... We often use 12 � n � n ! LE } AP = = { anagrams of , Pa 5 ! I pick a set of 2 items out of n total? A . k k !( n − k )! - D # I APPLE ftp.kp.EE > M - -2 J to represent the number of ways to choose k out of n items when M : reps a m : . order doesn’t matter. cnn.IM?N-InDxIn-2 - -521=60 Hmt (B) . I pick a set of 3 items out of n total? How many strings can we make by rearranging “BANANA”? I 2 23 ) 1 ni 6 ! y IAI We call this quantity “ n choose k ” . - - 3 ! reps - 3) ! 3 ! th We also sometimes refer to these as “binomial coe ffi cients.” 2 ! :3 ! A 's N 's : M : 243 ! I pick a set of k items out of n total? Total : Mt ⇒ tAmt=2÷ Q: Using this definition, what does 0 ! equal? IBI - K ) ! K ! ( n . 13 / 29 14 / 29 15 / 29 Binomial Coe ffi cients Anagramming III Coincidence? - - K O 'S Using this definition, what does 0 ! equal? How many bit strings can we make by k 1’s and ( n − k ) 0’s? Is there a relationship between: an ( not 't 1. Length n bit strings with k 1’s, and n? oh ' . IKO . On 1,12 , Oz 2. Ways of choosing k items from n when order doesn’t matter? = K . . - . . - - . N NO ! ! aO - - K K n Yes! n ! � n with → ordering : - � n - - � � - - Should we be surprised that = ? k ! . - K X 's k n − k I 's > k ! ( n - K ) ! X Repetitions : X : X O O - K n ! O 's n ! n - k ) ! O 's ( n - : K ) ! K ! - item - - xlo In strings t k b/w k ! ( n - K ) ! - bijection ⇒ Yin sets - Ik ) in in T - k members 2/0 - of choosing ways NOT ON members team ! K my team For 16 / 29 17 / 29 18 / 29

  4. ⇒ ⇒ ⇒ Putting It All Together: Space Team II Putting It All Together: Poker II ④ Exercise Sampling Without Replacement Among its 10 trainees, NASA wants to choose 3 to go to the How many 5-card poker hands form a full house (triple + pair)? How many ways can we sample k items out of n items, without moon, and 2 to go to Mars. They also don’t want anyone to do replacement , if: both missions. How many ways can they choose teams? I Order matters? Is Ii NIN - ktl ) - 1) Hn - 2) r In -= - K ) ! - - - - - How many 5-card poker hands form a straight (consecutive - in - items - cards), including straight flushes (same suit)? K If one member of the moon mission is designated as a captain, I Order does not matter? how many ways can they choose teams? ④ counting ) " ( second of er rule E) 6 i¥ How many 5-card poker hands form two pairs? ( YL ) k ! orderings per set Eoin . Tars We were able to use the First and Second rules of counting! 19 / 29 20 / 29 21 / 29 Sampling With Replacement When Repetitions Aren’t Uniform: Splitting Money When Repetitions Aren’t Uniform: Splitting Money How many ways can we sample k items out of n total items, with Alice, Bob, and Charlie want to split $6 amongst themselves. Second attempt: the “divider” point of view replacement , if: O First (naive and di ffi cult) attempt: the “dollar’s point of view” ¥ffBob#azµ I Order matters? -3×3-+3×-3=36 , ¥3 -_ Mk o , 00→⑧A08⑧#z • I X -N×N_ pg items Dollar orderndoesnt#ter . . ④ . o 's 6 - are dollars because indistinguishable K oos.o.EE#80zNsswpfiiYhng$6 . items . ,N Ai ice b Label I I Order does not matter? , rearranging . . . ABAAAAA# Iufagyet . , I } { I I I 111 , , . . . . . AAAAA qq.to#ARSANBARSf(8T)=&2. . ,24 { 1,1 9%5 I ? AAA } , . . repetitions b BA Ek Yoaysget 7. 2nd ! rule ④ CANNOT Use What can we do when order does not matter? 22 / 29 23 / 29 24 / 29

  5. ↳ “Stars and Bars” Application: Sums to k Summary Pick Your Strategy I How many ways can we choose n (not necessarily distinct) You have 12 distinct cards and 3 people. How many ways to: I k choices, always the same number of options at choice i " with non-negative numbers that sum to k ? " replace I Deal to the 3 people in sequence (4 cards each), and the regardless of previous outcome = ⇒ First Rule set negative xi order they received the cards matters? . 's TINI I Order doesn’t matter; same number of repetitions for each - incest . . desired outcome = ⇒ Second Rule f :p - ites I Indistinguishable items split among a fixed number of Yn - ! @ di ff erent buckets = ⇒ Stars and Bars k! I Deal to the 3 people in sequence (4 cards each), but order integers doesn’t matter? Food for thought: What if the numbers have to be positive ? to Xz Xs Xn • of .co/.of.oofFYnBo' § Xi . . . o , ¥¥÷ : " " Isao . 25 / 29 26 / 29 27 / 29 Pick Your Strategy II Pick Your Strategy III You have 12 distinct cards and 3 people. How many ways to: There are n citizens on 5 different committees. Say n > 15, and that each citizen is on at most 1 committee. I Deal 3 piles in sequence (4 cards each), and don’t distinguish How many ways to: the piles? I Assign a leader to each committee, then distribute all n − 5 remaining citizens in any way? I The cards are now indistinguishable. How many ways to deal so that each person receives at least 2 cards? I Assign a captain and two members to each committee? 28 / 29 29 / 29

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend