Counting and Probability Math 2320 For a finite set A, the number of elements of A is denoted by A. We have two important rules for counting. 1. Union rule: Let A and B be two finite sets. Then A B = A B A B. Essentially, when we add A and B, we double count the elements in the intersection. 2. Product rule: Let A and B be two finite sets. Then A B = A B. Since the product of sets is the set of all pairs, i.e., A B = { (x, y : x A, y B }, we can list the elements of A B in a rectangular array with A columns and B rows. Theorem. Let A and B be two finite sets with A = r and B = n. The number of functions from A to B is n r. Proof. Suppose that A = {a 1, a 2,..., a r } and B = {b 1, b 2,..., b n }. A function f : A B is determined by r values, f(a 1, f(a 2,..., f(a r. Since each f(a i is in B, there are n choices for the specific value f(a i. Therefore, there are n n... n = n r choices for the r values that determine f. In other words, there are n r possible functions from A to B. To connect this back to the Product rule, a function f : A B is determined precisely by a point ( f(a 1, f(a 2,..., f(a r in the product B B... B. Since there are n elements in B, this product has n r points, so there are n r functions. Theorem. Let A and B be two finite sets with r = A B = n. The number of injective functions from A to B is = n(n 1(n (n r 1. (n r! Proof. Just as in the previous proof, a function is determined by r values, f(a 1,..., f(a r. However, once we have chosen f(a 1, for f to be injective, there are only n 1 choices for f(a 2. Once we have chosen f(a 1 and f(a 2, there are n 2 choices for f(a 3. This continues until we have n r 1 choices for f(a r. Another way to view an injective function is as a point ( f(a 1, f(a 2, f(a 3,..., f(a r in the product B Applications. [ B { f(a 1 }] [ B { f(a 1, f(a 2 }] [ B { f(a 1,..., f(a r 1 }]. 1. Power set: The number of subsets of a set A is 2 A. Proof. Each subset B A determines a unique function f B : A {0, 1} by f B (x = 0 if x / B and f B (x = 1 if x B. Since there are 2 n functions A {0, 1}, there are 2 n subsets of A. 2. Choice with replacement, order matters: The number of ways to choose (with replacement r elements from an n-element set is n r. Proof. When order matters, choosing r elements from a set A with n elements is equivalent to choosing a function f : {0, 1,..., r} A. Since we are allowed to repeat our choices, we are allowed to choose any of the n r functions.
For example, if we roll 3 dice, the number of possible outcomes is 6 3, because rolling 3 dice is the same as choosing 3 numbers from {1, 2, 3,, 5, 6}, where repeats are allowed. Or, as another example, if a state has license plates consisting of 3 numbers followed by 3 letters (excluding the letter O, then there are 10 3 25 3 = 15,625,000 different license plates that can be issued. 3. Choice without replacement, order matters: The number of ways to choose (without replacement r elements from an n-element set is (n r!. Proof. When order matters, choosing r elements from a set A with n elements is equivalent to choosing a function f : {0, 1,..., r} A. Since we are not allowed to repeat our choices, we are only allowed to choose one of the (n r! injective functions. For example, if an organization with 10 people is going to select a governing body consisting of a president, vice president, and secretary, then there are 10! 7! = 10 9 8 = 720 different ways to choose the governing body.. Choice without replacement, order doesn t matter: The number of ways to choose (without replacement a collection of r elements from an n-element set is ( n r = (n r! r!. Proof. We start out by choosing r distinct elements from A, say f(1, f(,..., f(r. There are (n r! ways to choose these elements. However, these are in a specific order. So, we must count the number of such choices that gives us the same collection of elements. To do this, we notice that a reordering of the set S = {f(1,..., f(r} is just an injective function p : S S. There are r! 0! = r! such permuatations of S, i.e., there are r! different functions that yield the same set S. So, we take the number of ways to choose r distinct elements and we divide by the number of choices that are permutations of one another to get a total of (n r! r!. For example, if an organization with 10 people is going to select a board of directors consisting of 3 people (all of equal status, then there are ( 10 7 = 10! 7! 3! = 10 9 8 3 2 1 = 120 ways to select the board of directors. 5. Corollary: One way to rephrase the previous statement is as follows. The number of r-element subsets of an n-element set is ( n r = (n r! r!. In particular, if we group the number of subsets of A according to their size, we get n ( ( ( ( ( n n n n n 2 n = =.... r 0 1 2 n r=0 For example, if A = {a, b, c}, there are 1 subset with 0 elements:, 3 subsets with 1 element: {a}, {b}, {c}, 3 subsets with 2 elements: {b, c}, {a, c}, {a, b}, 1 subset with 3 elements: {a, b, c}, yielding a total of 8 = 1 3 3 1 sets. Notice that ( 3 = 3! ( 3 0 3! 0! = 1, = 3! ( 3 1 2! 1! = 3, = 3! = 3, and 2 1! 2! ( 3 = 3! 3 0! 3! = 1. Probability. The probability of an event occurring is the number of ways in which the event can occur divided by the total number of possible events. For example, suppose there are 35 people in a room and we want to figure the probability of 2 people sharing the same birthday. For our purposes, we want to consider all birthdays equally probable, so for simplicity, we will treat leap year birthdays on Feb 29 as the same as Feb 28. There are 365 possible birthdays and there are 35 people, so there are 365 35 possible birthday configurations for the group of people in question. Next, we want to
consider the number of ways that at least 2 of the birthdays are the same. The easiest way to compute this is to instead compute the number of ways that the birthdays are distinct and then subtract from the total. The number of ways to choose 35 distinct birthdays is 365! 330!. Therefore, the probability that there are no repeated birthdays is 365! 330! 365 36 363... 331 = 36535 365 365 365... 365 = 0.1856. In other words, there is only an 18.56% chance of no repeated birthdays, so there is a 81.% chance of at least one shared birthday. Examples. 1. There are 52 cards in a deck and 5 cards in a classic poker hand, so the number of possible poker hands is ( 52 = 52! 52 51 50 9 8 = = 13 51 5 9 16 = 2,598,960. 5 7! 5! 5 3 2 1 2. Suppose we want to compute the probability of having a full house, which consists of 3 of one number and 2 of another. A full house is determined by a choice of 2 numbers, and then a choice of 3 cards of the first number and 2 cards of the second number. For example, the full house QQQ77 would consist of the choice of Q and 7 followed by a choice of 3 suits for Q and 2 suits for 7. When we choose the two numbers, Q and 7, the order matters because our first choice will have 3 cards and our second choice will have 2 cards. Since there are 13 possible numbers, there are 13! = 13 12 possible ways to choose two numbers (without replacement, order mattering. Next, we need to ( choose 3 out of suits for the first number. Order no longer matters, so there are 3 = ways to choose 3 suits. Lastly, we need to choose 2 out of suits for the second number, which happens in ( = 6 different ways. Overall, there are 13 12 6 = 3,7 different ways to get a full house. Therefore, the probability of getting a full house is 37 2598960 =.001 = 0.1%. 3. Next suppose we want to compute the probability of having two pair. We choose two numbers and two suits per number, and a 5th card which is a different number. However, this time in the choice of the first two numbers, order doesn t matter since QQ77x is the same as 77QQx. There are ( ( 13 2 ways to choose the two numbers and ways to choose two suits for each of the two numbers. Once those two numbers have been chosen, there are choices for the 5th card, since there are 8 total cards whose value is equal to one of the two numbers already chosen. Therefore, the number of ways to get two pair is ( 13 123552 2598960 ( 2 ( = 123,552, and the probability of getting two pair is =.075 =.75%.. Suppose there are 6 red marbles, 3 blue marbles, and 1 green marbles in a bag. If we select marbles at random (without replacement, what is the probability of picking at least 2 red marbles? There are three options for at least 2 red marbles : we could pick red marbles, 3 red marbles and 1 other, or 2 red marbles and 2 other. Let s solve this problem considering that the order doesn t matter for our choices. First, picking red marbles out of 6 possible choices happens in ( 6 = 15 different ways. Second, picking 3 red marbles happens in ( ( 6 3 = 20 different ways; picking 1 non-red marble happens in 1 = different ways; so picking 3 red and 1 non-red happens in 20 = 80 different ways. Third, picking 2 red marbles happens in ( 6 = 15 different ways; picking 2 non-=red marbles happens in ( = 6 different ways; so picking 2 red and 2 non-red happens in 15 6 = 90 different ways. Overall, the number of ways to pick at least 2 red marbles is 15 80 90 = 185. The number of ways of picking marbles out of 10 is ( 10 = 210. Therefore, the probability of picking at least 2 red marbles is 185/210 =.8809 = 88.09%. 11!
Exercises 1. Consider the set A = {a, b, c, d, e, f}. Each subset B A is determined by a function f B : A {0, 1}, i.e., each subset is determined by a string of 0 s and 1 s. For instance, the subset {a, c} corresponds to the string 101000. Grouping the subsets by number of elements is the same as grouping the strings by the numbers of 1 s that occur. Group all 6 strings by the number of 1 s that occur in each string. Use this to verify that, for r = 0, 1, 2, 3,, 5, 6, there are ( 6 r subsets of A with r elements. 2. Consider the set of hexadecimal digits {0, 1, 2, 3,, 5, 6, 7, 8, 9, A, B, C, D, E, F}. A string of digits is an ordered list of digits; for example, 623AB is a string with 6 digits. (a How many strings consisting of 5 hexadecimal digits are there? (b How many strings consisting of 5 distinct hexadecimal digits are there? (c How many subsets consisting of 5 distinct hexadecimal digits are there? 3. There are 10 employees at a company, but their favorite restaurant for lunch can only seat 8 people. (a How many different combinations of 8 people can go to lunch together? (b In how many different ways can 8 people be chosen and then seated at the restaurant?. Suppose that a state s license plates consist of 2 letters (excluding the letter O followed by numbers. (a How many license plate configurations are there? (b How many license plate configurations are there with no repeated letters? (c How many license plate configurations are there where no two consecutive letters are the same? 5. A coin is flipped 5 times, each time landing either heads or tails. (a What is the probability that tails occurs at least 3 times? (b What is the probability that tails occurs either 2 or 3 times? 6. A bag contains red marbles and 5 black marbles. Four marbles are extracted from the bag without replacement. Compute the probability that (a all four marbles are red. (b all four marbles are black. (c one marble is red and three marbles are black. (d at least one marble is black. 7. There are 10 pieces of candy in a bag and 3 of them are red. If four pieces of candy are chosen at random, compute the probability that (a at least 1 of them is red. (b at least 2 of them are red. (c none of them are red. (d all of them are red.
Exercises 1. r ( 6 r subsets with r elements 0 1 000000 1 6 100000, 010000, 001000, 000100, 000010, 000001 2 15 110000, 101000, 100100, 100010, 100001, 011000, 010100, 010010, 010001, 001100, 001010, 001001, 000110, 000101, 000011 3 20 111000, 110100, 110010, 110001, 101100, 101010, 101001, 100110, 100101, 100011, 011100, 011010, 011001, 010110, 010101, 010011, 001110, 001101, 001011, 000111 15 111100, 111010, 111001, 110110, 110101, 110011, 101110, 101101, 101011, 100111, 011110, 011101, 011011, 010111, 001111 5 6 111110, 111101, 111011, 110111, 101111, 011111 6 1 111111 2. (a There are 16 5 = 1,08,576 strings consisting of 5 digits. (b There are 16! 11! = 16 15 1 13 12 = 52,160 strings consisting of 5 distinct digits. (c There are ( 16 subsets consisting of 5 distinct digits. 3. (a There are ( 10 5= 16! 11! 5! = 16 15 1 13 12 5 3 2 1 =,368 8= 10! 2! 8! = 10 9 2 1 =5 different combinations of 8 people. (b There are 10! 2! = 1,81,00 different ways to seat 8 out of 10 people at the restaurant.. (a There are 25 2 10 = 6,250,000 different license plate configurations. (b There are 25 2 10 = 6,000,000 different license plate configurations with no repeated letters. (c This one was a typo. As it was originally listed, the answer is the same as the previous question. I meant to ask where no two consecutive numbers are the same. The answer to this question that I didn t ask is 25 2 10 9 9 9 =,556,250 different configurations with no two consecutive numbers the same. 5. (a This is similar to #1, actually. If we label a heads by 0 and a tails by 1, then each set of 5 coin flips corresponds to a string of 5 digits each of which are either 0 or 1. There are 2 5 = 32 total scenarios. Having at least 3 tails corresponds to picking a subset of at least 3 elements from a 5 element set. There are ( 5 3 ( 5 ( 5 5 = 10 5 1 = 16 subsets of at least 3 elements, so the probability of at least 3 tails is 16/32 = 50%. (b The number of subsets of a 5 element set consisting of exactly 2 or 3 elements is ( ( 5 5 = 10 10 = 20, 2 3 so the probability of exactly 2 or 3 tails is 20/32 = 62.5%. 6. The number of ways to draw marbles out of 9 is ( 9 = 126. (a The number of ways to draw red marbles is ( = 1, so the probability is 1/126.
(b The number of ways to draw black marbles is ( 5 = 5, so the probability is 5/126. (c The number of ways to draw 1 red marble and 3 black marbles is ( 1( 5 3 = 0, so the probability is 0/126 = 20/53. (d The number of ways to draw at least one black marble is the the complement to the number of ways to draw no black marbles, which was 1. Therefore, the probability of drawing at least one black marble is 125/126. Another way to calculate the number of ways to draw at least one black marble is ( ( ( ( ( ( ( ( 5 5 5 5 = 20 60 0 5 = 125. 3 1 2 2 1 3 0 7. There are ( 10 = 210 ways to choose out of 10 candies. (a We can calculate the number of ways to pick at least 1 red candy directly or indirectly. Directly: ( 3 1 ( 7 3 ( 3 2 ( 7 2 ( 3 3 ( 7 = 175. 1 Indirectly, we calculate the number of ways to choose no reds, ( 3 0( 7 = 35, and subtract to get 210 35 = 185. Either way, we calculate the probability of at least 1 red candy to be 175/210 = 5/6. (b The number of ways to pick at least 2 red candies is ( ( ( ( 3 7 3 7 = 70, 2 2 3 1 so the probability of at least 2 red candies is 70/210 = 1/3. (c The probability that none of them are red is 35/210 = 1/6. (d The probability that all of them are red is 0 because there are only 3 red candies in total.