1 / 64

Counting and probability

Counting and probability. What do you mean by counting? How do you count things in daily life? Counting the European way or the English speaking way? 8 days a week (not the Beatles song)?. 1.1 Linear Series Rule.

casimir-lel
Download Presentation

Counting and probability

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. Counting and probability

  2. What do you mean by counting? • How do you count things in daily life? • Counting the European way or the English speaking way? • 8 days a week (not the Beatles song)?

  3. 1.1 Linear Series Rule. If m and n are integers such that m£ n, then there are n-m+1 integers from m to n inclusive. 1.1 Linear Series Rule. Example 1: How many integers are there in the sequence 10, 11, 12, …, 19, 20? Example 2: How many integers are there in the sequence -8,-7,-6,…-1,0,1,2,…4, 5? Example 3: How many integers are there in 0 to 1000 inclusive, that are divisible by 3.

  4. 1.1 Linear Series Rule. If m and n are integers such that m£ n, then there are n-m+1 integers from m to n inclusive. 1.1 Linear Series Rule. Example 1: How many integers are there in the sequence 10, 11, 12, …, 19, 20? Ans: 20 – 10 + 1 = 11 Example 2: How many integers are there in the sequence -8,-7,-6,…-1,0,1,2,…4, 5? Ans: 5 – (–8) + 1 = 14 Example 3: How many integers are there in 0 to 1000 inclusive, that are divisible by 3. The integers are 0,3,6,9,…,996,999 , which are in the form 3k, where k = 0,1,2,…,333. Hence there are 333-0+1 = 334 integers from 0 to 1000 which are divisible by 3.

  5. What is Probability? A coin has a 50% chance of landing heads. What does that mean? • The coin will land heads 50% of the time? not really. • The coin will land heads approximately 50% of the time? Then the probability is approximately 50%, not exactly 50%. It means that the fraction of the time that the coin lands heads will get arbitrarily close to 50% as the number of coin tosses increases without bound.

  6. The Sample Space • An experiment is a procedure that leads to an outcome. • Toss a coin. • We observe a characteristic of the outcome. • Which side landed up? • The sample space is the set of all possible observations/ outcomes. • Sample space = {H, T} • An event is a collection of possible observations, i.e., a subset of the sample space. • E(H) = 1 • A sample space is the set of all possible outcomes of a random process or experiment. An event is a subset of a sample space.

  7. Some points to ponder. • The processes are random, i.e. some set of outcomes is sure to occur but it is impossible to predict with certainty which one. • We will consider only finite sample spaces. • The probability of an event is the sum of the probabilities of its individual members. • If the members of the sample space are equally likely, then P(E) = |E|/|S|. • If the n members of the sample space are equally likely, then the probability of each member is 1/n. • Examples Toss a coin, P(H) = 1/2. Roll a die, P(3) = 1/6.

  8. Possibility Trees and the Multiplication Rule

  9. Often, an experiment may be viewed as a sequence of simple procedures, or sub-experiments. • An outcome of the experiment will be a sequence of outcomes of the sub-experiments. • To analyze the experiment, we should first analyze the sub-experiments. • Draw three cards, with replacement, from a shuffled deck • 1st sub-experiment: Draw the 1st card. • 2nd sub-experiment: Draw the 2nd card. • 3rd sub-experiment: Draw the 3rd card. • What is the sample space? Are the outcomes equally likely? What if we drew without replacement?

  10. A possibility tree Starts at a root. • Has one level for each sub-experiment. • At each level, shows a set of branches for all the possibilities (sample space) of that sub-experiment. • If • sub-experiment #1 has m possible outcomes • and • sub-experiment #2 has n possible outcomes (no matter how sub-experiment #1 turned out), • then • the two sub-experiments in sequence have mn possible outcomes. Multiplication Rule If an operation consists of a sequence of steps/events E1, E2…Ek and if each Ei can be performed in ni ways regardless of how the previous steps E1, …Ei-1 were performed (i.e. independent), then the entire operation can be performed in n1´n2´…´nk ways.

  11. Examples • Toss 5 coins: 2  2  2  2  2 = 32 possibilities • Roll 3 dice: 6  6  6 = 216 possibilities • Draw 5 cards (without replacement): 52  51  50  49  48 = 311,875,200 possibilities Example 1:What is the maximum number of possible 3-letter English words with the pattern consonant-vowel-consonant? Example 2: How many odd numbers greater than 3000 can be formed by using each of the digits 1, 2, 3, and 4 once? Example 3:A car license plate has 3 letters of alphabet followed by 4 single digit numbers. How many different car licenses can be issued (a) if repetitions of alphabets/numbers in the license plate is allowed; (b) if repetitions are not allowed? Example 4: (Limitations of the Multiplication Rule) Two teams A and B are to play each other repeatedly until one wins two games in a row, or until a total of 3 games. How many ways can a tournament be played?

  12. A wins B wins A wins B wins A wins B wins A wins B wins A wins B wins Why do the rules of multiplication not apply here?

  13. Example 5: Three officers – A president, a treasurer, and a secretary, are to be chosen from among 4 people: A, B, C, D. Suppose that A cannot be president, and either C or D must be secretary. How many ways can the officers be chosen? Selecting three officers can be broken down to the following tasks: Step 1: Select the president : 3 ways. Step 2: Select the treasurer : 3 ways. Step 3: Select the secretary : 2 ways. Total number of performing the task = 3 .3 .2 ways

  14. C D A B C D D C A D start C B D A C D B C Example 5: Three officers – A president, a treasurer, and a secretary, are to be chosen from among 4 people: A, B, C, D. Suppose that A cannot be president, and either C or D must be secretary. How many ways can the officers be chosen? • Goal Re-ordering is a possible way to by-pass dependency of tasks • Select the president: 3 ways • Select the treasurer: number of ways DEPENDENT on the outcome of step 1!!! • Select the secretary: number of ways DEPENDENT on the outcome of step 2, which is in turn, DEPENDENT on step 1.

  15. (Goal Re-ordering is a possible way to by-pass dependency of tasks) Step 1: Select the secretary : 2 ways (C or D). Step 2: Select the president : 2 ways regardless of the choice taken in step 1 (person B with the remaining person from step 1) Step 3: Select the treasurer : 2 ways. (person A with the person remaining from step 2) Total number of performing the task = 2 * 2 * 2 ways C D A B C D D C A D start C B D A C D B C

  16. Each step is independent of the choices of previous step. The number of ways of each step is independent of the choices of the previous step

  17. Permutations

  18. A permutation of the elements of a set is an ordering of those elements. • Distinct orderings are distinct permutations. • The permutations of {a, b, c} are abc, acb, bac, bca, cab, and cba. • a permutation of a set S of n distinct objects is an ordered list of these objects • an r-permutation is an ordered list of r elements of S • S={1,2,3}, all permutations={(1,2,3),(2,1,3),(1,3,2),(2,3,1),(3,1,2),(3,2,1)} • all 2-permutations={(1,2),(2,1),(1,3),(3,1),(2,3),(3,2)} • the number of r-permutations of a set S with n elements is written as P(n,r). • If n and r are integers such that , then • P(n,r) = n*(n-1)*(n-2)*...*(n-r+1) = n!/(n-r)! • P(n,n) = n! /(n-n)! = n!

  19. 6. CIRCULAR PERMUTATIONS • The number of ways of permuting r objects from a set of n objects in a circle (in which two arrangements are the same when one is a rotation of the other) is P(n,r) / r. • 1. How many different ways can a salesman visit 8 cities? • 2. How many different ways can 10 horses in a race win, place and show (come in first, second, third)?

  20. Addition and Difference rule Theorem: Let {A1, …, An} be a partition of a set A. Then |A| = |A1| + … + |An|. Corollary: Let {A1, …, An} be a collection of pair wise disjoint finite sets. Then |A1 … An| = |A1| + … + |An|.

  21. Addition Rule: • If a finite set A = A1È A2 È...È An where all the Ai’s are mutually disjoint, then |A| = |A1| + |A2|+ ... + |An| • Difference Rule: • If A is a finite set and BÍA, then |A – B| = |A| – |B|

  22. Set of all code words of length £3 Set of all code words of length 1 Set of all code words of length 2 Set of all code words of length 3 Example 1: A computer access code word consists of one to three letters, chosen from the 26 alphabets, with repetitions allowed. How many code words are possible? • By addition rule: |Set of all code words of length £3 | = | Set of all code words of length 1 | + | Set of all code words of length 2 | + | Set of all code words of length 3 |

  23. Set of all code words of length £3 Set of all code words of length 1 Set of all code words of length 2 Set of all code words of length 3 Example 1: A computer access code word consists of one to three letters, chosen from the 26 alphabets, with repetitions allowed. How many code words are possible? • Number of code words of length 1 = 26 • Number of code words of length 2 = 262 (Multiplication Rule) • Number of code words of length 3 = 263 (Multiplication Rule) • Total number of code words = 26 + 262 + 263 (Addition Rule)

  24. Set of selections of 2 books 1 book from CS and 1 book Math 1 book from CS and 1 book from Chemistry 1 book from Math and 1 book from Chemistry Basic Rules: Addition/Difference Rule Example 2: There are 15 different computer science books, 12 different math books, and 10 different chemistry books on the shelf. How many ways can we select 2 books, each from a different subject? • By addition rule: |Set of selections of 2 books| = | Set of selection of 1 book from CS and 1 book from Math | + | Set of selection of 1 book from CS and 1 book from Chem | + | Set of selection of 1 book from Math and 1 book from Chem |

  25. Set of selections of 2 books 1 book from CS and 1 book Math 1 book from CS and 1 book from Chemistry 1 book from Math and 1 book from Chemistry + + Example 2: There are 15 different computer science books, 12 different math books, and 10 different chemistry books on the shelf. How many ways can we select 2 books, each from a different subject? 15 ´ 12 (M.R.) 15 ´ 10 (M.R.) 12 ´ 10 (M.R.)

  26. Basic Rules: Addition/Difference Rule Example 3: A group of eight people are attending the movies together. If two of the eight people are enemies and do not want to sit next to each other, how many ways can this group sit in a row, such that the two enemies are separated? Answer: Different arrangements of 8 people in a row = 8! (by multiplicaton rule) How? Step 1: Sit the 1st person: 8 ways Step 2: Sit the 2nd person: 7 ways regardless of outcome of step 1. Step 3: Sit the 3rd person: 6 ways regardless of outcome of step 1-2. … Different arrangements of 8 people in a row where the 2 enemies sit next to each other Different arrangements of 8 people in a row where the 2 enemies sit apart

  27. Basic Rules: Addition/Difference Rule Example 3: A group of eight people are attending the movies together. If two of the eight people are enemies and do not want to sit next to each other, how many ways can this group sit in a row, such that the two enemies are separated? Answer: Different arrangements of 8 people in a row = 8! = 2*7! (by multiplicaton rule) How? Step 1: Sit the 2 enemies together: 2*7 ways Step 2-7: Sit the remaining 6 people: 6*5*4*3*2*1 Different arrangements of 8 people in a row where the 2 enemies sit next to each other Different arrangements of 8 people in a row where the 2 enemies sit apart OR… Another way of looking at it: Step 1: Combine the 2 enemies as 1 person and take it as an arrangement of 7 people to 7 chairs, (7!). Step 2: Different ways of arranging the 2 enemies to sit side-by-side: 2 ways.

  28. Basic Rules: Addition/Difference Rule Example 3: A group of eight people are attending the movies together. If two of the eight people are enemies and do not want to sit next to each other, how many ways can this group sit in a row, such that the two enemies are separated? Answer: Different arrangements of 8 people in a row = 8! = 2*7! (by multiplicaton rule) Different arrangements of 8 people in a row where the 2 enemies sit next to each other Different arrangements of 8 people in a row where the 2 enemies sit apart Answer = 8! – 2*7! (Difference Rule)

  29. Basic Rules: Addition/Difference Rule Example 4: How many integers are there in 1000 to 9999 that contain at least a digit 5. Answer = (Number of integers in 1000 to 9999) – (Number of integers in 1000 to 9999 that do not contain a digit 5) (Difference Rule) = (9999 – 1000 + 1) – 8.93 (Linear Series Rule) (Multiplication Rule) = 3168 If S is a finite sample space and A is an event in S, then Page 298 example 6.3.3

  30. Basic Rules: Addition/Difference Rule Example 5: How many 3 digit numbers have at least one digit repeated? Answer = Number of 3 digit numbers – Number of 3 digit numbers which have NO digit repeated (Difference Rule) (9 *10 *10) Multiplication Rule: Step 1: Choose hundredths digit (must exclude leading ‘0’, therefore only 9 ways) Step 2: Choose tenths digit Step 3: Choose units digit (9 *9 *8) Multiplication Rule: Step 1: Choose hundreths digit (must exlude leading ‘0’) Step 2: Choose tenths digit (10 ways, excluding the digit in step 1. Therefore 9 ways) Step 3: Choose units digit

  31. Basic Rules: Inclusion-Exclusion Rule

  32. 1.4 Inclusion-Exclusion Rule: • (For 2 sets) Given any sets A and B, • |A È B| = |A| + |B| – |A Ç B| • (For 3 sets) Given any sets A, B and C, • |A È B È C | = |A| + |B| + |C| – |A Ç B| – |A Ç C| – |B Ç C| + |A ÇB Ç C| • (For n sets) Given any sets A1 … An, | A1È … È An| = | Ai | – | AiÇ Aj| + | AiÇAjÇ Ak| – … The pattern is to add “one at a time”, subtract “two at a time”, and add “three at a time” and so on.

  33. Multiples of 5 Multiples of 3 All integers fom 1 to 1000 Basic Rules: Inclusion-Exclusion Rule Example 1: How many integers from 1 through 1000 are multiples of 3 or 5? How many are neither multiples of 3 nor 5? Answer: |{Integers of multiples of 3 or 5}| = |{Integers of multiples of 3}| + |{Integers of multiples of 5}| – |{Integers of multiples of 3 and 5}| (Inclusion-Exclusion Rule)

  34. Basic Rules: Inclusion-Exclusion Rule Example 1: How many integers from 1 through 1000 are multiples of 3 or 5? How many are neither multiples of 3 nor 5? Answer: |{Integers of multiples of 3 or 5}| = |{Integers of multiples of 3}| + |{Integers of multiples of 5}| – |{Integers of multiples of 3 and 5}| (Inclusion-Exclusion Rule) |{Integers of multiples of 3}| = |{3k | where k = 1,2,…333}| = 333 |{Integers of multiples of 5}| = |{5k | where k = 1,2,…200}| = 200 |{Integers of multiples of 3 and 5}| = |{15k | where k = 1,2,…66}| = 66 Ans = 333 + 200 – 66= 467

  35. Basic Rules: Inclusion-Exclusion Rule Example 1: How many integers from 1 through 1000 are multiples of 3 or 5? How many are neither multiples of 3 nor 5? Question: How many are neither multiples of 3 nor 5? Answer: {Int from 1..1000} -{Int from 1..1000 with are multiples of 3 or 5} 1000 467 Ans = 1000-467 (By difference rule) = 533 How many primes are there between 1 and 100? The non-primes must be multiples of 2, 3, 5, or 7, since the square root of 100 is 10.

  36. Counting subsets of a Set:Combinations

  37. Definition: • An r-combination of a set of n elements is a subset of r elements taken from the set of n elements ( ). • Notation: • The number of r-permutations of a set of n elements is denoted as C(n,r), also as and • Note: A combination is an unordered selection: you are selecting a ‘set’, and ordering is not important in sets.

  38. Those teams which involve the 2 ‘friends’ Those teams which do not involve the 2 ‘friends’ Theorem: The number of r-combinations of a set of n elements is C(n, r) = n!/[r!(n – r)!]. Corollary: For all n 0 and 0 rn, P(n, r) = r! C(n, r). Calculator tools Example 1: You are to select five members from a group of twelve to form a team. (a) How many distinct five-person teams can be selected? (b) If two of them insist on working together as a pair, such that any team must either contain both of neither. How many five person teams can be formed? Answer: (a) C(12,5) All 5-person teams satisfying the ‘2-friends’ constraint. C(10,3) C(10,5)

  39. All 5-person teams that do not contain the two enemies, say A and B C(10,4) C(10,5) C(10,4) Example 2 You are to select five members from a group of twelve to form a team. If two of them insist on working apart,how many five person teams can be formed? 1’st version using addition rule Those teams which contain A but not B Those teams which contain B but not A Those teams which do not contain A nor B Step 1: select the A: 1 way + + Step 2: select the remaining people except B: C(10,4)

  40. All 5-person teams C(12,5) Example 2 You are to select five members from a group of twelve to form a team. If two of them insist on working apart,how many five person teams can be formed? 2’nd version Those teams with the two enemies together Those teams with the two enemies apart Step 1: select the two enemies: 1 way Ans: C(12,5) – C(10,3) C(10,3) Step 2: select the remaining 3 people: C(10,3)

  41. Example : A group of twelve consists of five men and seven women. (a) How many five-person teams can be chosen that consists of three men and two women? (b) How many five-person teams contain at least one man? (c) How many five-person teams contain at most one man? (a) Answer: Step 1: choose the men: C(5,3) ways Step 2: choose the women: C(7,2) ways (regardless of the choices made in step 1) Multiplication rule: C(5,3) x C(7,2) (b) Answer: Number of 5-person teams that contain at least one man = Number of 5-person teams – Number of 5-person teams that do not contain any men (all women). (DIFFERENCE RULE) = C(12,5) – C(7,5)

  42. (c) Answer: Number of 5-person teams that contain at most one man = Number of 5-person teams that contain no men + Number of 5-person teams that contain 1 man (BY ADDITION RULE) = (C(5,0) x C(7,5)) Step 1: Choose 0 men from 5 men Step 1: Choose 5 women from 7 women + (C(5,1) x C(7,4)) Step 1: Choose 1 man from 5 men Step 2: choose 4 women from 7 women Example 4: 10 people are to sit around two round tables. The first table has 6 chairs, the second table has 4 chairs. (a) How many ways can this be done? (b) How many ways can this be done if two of them need to sit together?

  43. (a) Answer (version#1): Step 1: Choose 6 people to sit on the first table C(10,6) Step 2: Arrange the 6 people on the first table 5! (Circular Permutation) Step 3: Arrange the remaining 4 on the second table. 3! (Circular Permutation) (BY MULTIPLICATION RULE) = C(10,6) x 5! x 3! = 10!/24 (a) Answer (version#2): Step 1: Permute 6 people from 10 circularly around the first table P(10,6)/6 Step 2: Arrange the remaining 4 on the second table. 3! (Circular Permutation) (BY MULTIPLICATION RULE) = P(10,6)/6 x 3! = 10!/24

  44. (b) Answer (version#1): BY ADDITION RULE Number of sitting arrangements where the two sit on the 1st table + Number of sitting arrangements where the two sit on the 2nd table BY MULTIPLICATION RULE Step 1: Put the two on the first table: 1 way Step 2: Select 4 more to join them: C(8,4) Step 3: Permute them around the table : 5! Step 4: Permute the remaining 4 circularly on 2nd table: 3! BY MULTIPLICATION RULE Step 1: Put the two on the second table: 1 way Step 2: Select 2 more to join them: C(8,2) Step 3: Permute them around the table: 3! Step 4: Permute remaining 6 circularly on 1st table: 5! = (C(8,4)x5!x3!) + (C(8,2)x3!x 5!) Example 4: 10 people are to sit around two round tables. The first table has 6 chairs, the second table has 4 chairs. (a) How many ways can this be done? (b) How many ways can this be done if two of them need to sit together?

  45. (b) Answer (version#2): BY ADDITION RULE Number of sitting arrangements where the two sit on the 1st table + Number of sitting arrangements where the two sit on the 2nd table BY MULTIPLICATION RULE Step 1: Put the two on the first table: 1 way Step 2: Permute 4 from 8 circularly on the 2nd table: P(8,4)/4 Step 3: Permute the 6 circularly on 1st table: 5! BY MULTIPLICATION RULE Step 1: Put the two on the second table: 1 way Step 2: Permute 6 from 8 circularly on the 1st table: P(8,6)/6 Step 3: Permute remaining 4 circularly on 2nd table: 3! = (P(8,4)/4 x 5!) + (P(8,6)/6 x 3!)

  46. 1 2 3 3 5 6 7 8 • Permutations of Sets with Repeated ElementsTheorem: • Suppose a set contains • n1 indistinguishable elements of one type, • n2 indistinguishable elements of one type, • and so on, through k types, where n1 + n2 + … + nk = n. • Then the number of (distinguishable) permutations of the n elements is n!/(n1!n2!…nk!). How many eight-bit strings have exactly three 1’s? • Choose a subset of 3 positions out of 8 • to contain 1’s. • Once 1. Above has been chosen the remaining • Positions are filled with 0’s. C(8, 5) ways 1 way

  47. How many permutations are there of the letters in the word MISSISSIPPI? IIMSSPISSIP, ISSSPMIIPIS, PIMISSSSIIP and so on. 11!/(4!4!2!1!) = 34650 How many different numbers can be formed by permuting the digits of the number 444556? 6!/(3!2!1!) = 720/(6  2  1) = 60.

  48. R-Combinations with repetitions allowed

  49. A multiset is a set, except that repetitions are allowed. • For example, {1, 1, 2, 2, 2, 3, 4} is a multiset. • An r-combination with repetitions allowed of a set of n elements is a multiset of r objects, with each member taken from the set of n elements. • Definition (r-combinations from a multi-set): • Given a set X of n objects, an r-combination with repetition allowed (or r-combination with a multi-set of size r) is an unordered selection of elements taken from X with repetition allowed. • Theorem: The number of r-combination with repetition allowed drawn from a set of n elements is C(r+n–1, r). • Example: 3-combinations from a set {a,b,c,d} • [a,a,a]; [a,a,b]; [a,a,c]; [a,a,d] • [a,b,b]; [a,b,c]; [a,b,d]; Total Number = 20 = C(3+4-1 , 3) • [a,c,c]; [a,c,d]; [a,d,d]; • [b,b,b]; [b,b,c]; [b,b,d]; • [b,c,c]; [b,c,d]; [b,d,d]; • [c,c,c]; [c,c,d]; [c,d,d]; • [d,d,d]

  50. Category a Category b Category c Category d X X X | | | X X | X | | X X X X X | X | | X X X X | | X | X X X X | X | X X | X X X [a,a,a] X X X [a,a,b] [a,b,d] [a,c,d] [b,c,c] • Problem generalized: • r-combination = putting r crosses • From a set of n elements = putting n-1 ‘|’s in between crosses. • Reduces to the same problem of assigning 2-bits (X and |) to r+n-1 positions. (Permuting r+n-1 positions from a multi-set of {X,|} Selection Represented by: [a,a,a] [a,a,b] [a,b,d] [a,c,d] [b,c,c]

More Related