1 / 31

CS322

Week 9 - Friday. CS322. Last time. What did we talk about last time? Partial orders Total orders Basic probability Event Sample space Monty Hall Multiplication rule. Questions?. Logical warmup.

illias
Download Presentation

CS322

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Week 9- Friday CS322

  2. Last time • What did we talk about last time? • Partial orders • Total orders • Basic probability • Event • Sample space • Monty Hall • Multiplication rule

  3. Questions?

  4. Logical warmup • There are 10 thieves who have just stolen an enormous pile of loot: gold, jewels, solid state drives, and so on • The thieves need to find a way to divide it all equally • Give an algorithm such that each of the 10 thieves believe that he is getting at least 1/10 of the loot • Hint: When you were a kid, how did your mother have you and your brother or sister divide the last piece of cake?

  5. Permutations

  6. Permutations of letters in a word • How many different ways can the letters in the word "WOMBAT" be permuted? • How many different ways can "WOMBAT" be permuted such that "BA" remains together? • What is the probability that, given a random permutation of "WOMBAT", the "BA" is together? • How many different ways can the letters in "MISSISSIPPI" be permuted? • How many would it be if we don't distinguish between copies of letters?

  7. Permuting around a circle • What if you want to seat 6 people around a circular table? • If you only care about who sits next to whom (rather than who is actually in Seat 1, Seat 2, etc.) how many circular permutations are there? • What about for n people?

  8. Permutations of selected elements • An r-permutation of a set of n element is an ordered selection of r elements from the set • Example: A 2-permutation of {a, b, c} includes: • ab • ac • ba • bc • ca • cb • The number of r-permutations of a set of n elements is P(n,r) = n!/(n – r)!

  9. r-permutation examples • What is P(5,2)? • How many 4-permutations are there in a set of 7 objects? • How many different ways can three of the letters in "BYTES" be written in a row?

  10. Disjoint Sets

  11. Addition rule • If a finite set Aequals the union of k distinct mutually disjoint subsets A1, A2, … Ak, then: N(A) = N(A1) + N(A2) + … + N(Ak)

  12. Addition rule example • How many passwords are there with length 3 or smaller? • Assume that a password is only made up of lower case letters • Passwords with length 3 or smaller fall into 3 disjoint sets • Number of passwords with length 1 • Number of passwords with length 2 • Number of passwords with length 3 • Total passwords = 26 + 262 + 263 = 18278

  13. Difference rule • If A is a finite set and B is a subset of A, then N(A – B) = N(A) – N(B) • Example: • Recall that a PIN has 4 digits, each of which is one of the 26 letters or one of the 10 digits • How many PINs contain repeated symbols? • What is the probability that a PIN contains a repeated symbol?

  14. Inclusion/exclusion rule • If A, B, C are any finite sets, then N(A B) = N(A) + N(B) – N(A  B) • And, N(A B  C) = N(A) + N(B) + N(C) – N(A  B) – N(A  C) – N(B  C) + N(A  B  C)

  15. Inclusion exclusion example • How many integers from 1 through 1,000 are multiples of 3 or multiples of 5? • How many integers from 1 through 1,000 are neither multiples of 3 nor multiples of 5?

  16. Inclusion exclusion example • Consider a survey of 50 students about the programming languages they know • The results are: • 30 know Java • 18 know C++ • 26 know ML • 9 known both Java and C++ • 16 know both Java and ML • 8 know both C++ and ML • 47 know at least one of the three • How many students know none of the three? • How many students know all three? • How many students know Java and C++ but not ML? • How many students know Java but neither C++ nor ML?

  17. Combinations Student Lecture

  18. Combinations

  19. Subsets of sets • How many different subsets of size r can you take out of a set of n items? • Subset of size 3 out of a set of size 5? • Subset of size 4 out of a set of size 5? • Subset of size 5 out of a set of size 5? • Subset of size 1 out of a set of size 5? • This is called an r-combination, written

  20. Permutations and combinations • In r-permutations, the order matters • In r-combinations, the order doesn't • Thus, the number of r-combinations is just the number of r-permutations divided by the possible orderings

  21. Combinations example • How many ways are there to choose 5 people out of a group of 12? • What if two people don't get along? How many 5 person teams can you make from a group of 12 if those two people cannot both be on the team?

  22. Poker examples • How many five-card poker hands contain two pairs? • If a five-card hand is dealt at random from an ordinary deck of cards, what is the probability that the hand contains two pairs?

  23. r-combinations with repetitions • What if you want to take r things out of a set of n things, but you are allowed to have repetitions? • Think of it as putting r things in n categories • Example: n = 5, r = 4 • We could represent this as x||xx|x| • That's an rx's and n – 1 |'s

  24. r-combinations with repetitions • So, we can think of taking an r-combination with repetitions as choosing r items in a string that is r + n – 1 long and marking those as x's • Consequently, the number of r-combinations with repetitions is

  25. Example • Let's say you grab a handful of 10 Starbursts • Original Starbursts come in • Cherry • Lemon • Strawberry • Orange • How many different handfuls are possible? • How many possible handfuls will contain at least 3 cherry?

  26. Handy dandy guide to counting • This is a quick reminder of all the different ways you can count things:

  27. Exam 2 Post Mortem

  28. Quiz

  29. Upcoming

  30. Next time… • Binomial theorem • Probability axioms • Expected values

  31. Reminders • Work on Homework 7 • Due tonight before midnight • Keep reading Chapter 9

More Related