Presentation is loading. Please wait.

Presentation is loading. Please wait.

Counting and Probability

Similar presentations


Presentation on theme: "Counting and Probability"— Presentation transcript:

1 Counting and Probability
1

2 Counting Counting elements in a list:
how many integers in the list from 1 to 10? how many integers in the list from m to n? (assuming m ≤ n) n – m + 1

3 How Many in a List? How many positive three-digit integers are there?
(this means only the ones that require 3 digits) 999 – 99 = (999 3 or fewer digit numbers – 99 2 or fewer) 999 – = (100, 101, …, 999 – previous slide) 91010 = (9 hundreds digits, 10 tens digits, 10 unit digits) How many three-digit integers are divisible by 5? 20  5, 21  5, …,  5 count the integers between 20 and 199 199 – = 180 Smaller example where we can actually write them all out number of integers between 10 and 35 divisible by 3 12 = 3*4, 15=3*5, 18=3*6, 21 = 3*7, 24=2*8, 27=3*9, 30=3*10, 33=3*11 = 8 Proof of “The number of elements in the list b to e is (e-b+1)” Base Case (e=x,b=x) e-b+1 = x-x+1 = 1 Inductive Hypothesis (e=k,b=x) size of list = e – b + 1 = k-x+1 Inductive Step (e=k+1,b=x) show: size of list = e-b+1=(k+1)-x+1 proof: b….k  b…k, k+1 size of (b…k) = k-x+1 by the IH size of (k+1) = 1 size of (b…k+1) = k-x+1+1 = (k+1) – x + 1

4 The breakfast problem Bill eats Rice Krispies, Cornflakes, Raisin Bran, or Cheerios. Bill drinks coffee, orange juice, or milk. How different types of breakfast can Bill have?

5 The multiplication rule
If the 1st step of an operation can be performed n1 ways And the 2nd step can be performed n2 ways And the kth step can be performed nk ways Then the operation can be performed n1n2 ∙ ∙ ∙ nk ways

6 Using the multiplication rule for selecting a PIN
Number of 4 digit PINs of (0,1,2,.) with repetition allowed = 4  4  4  4 = 256 with no repetition allowed = 4  3  2  1 = 24 Extra rules : . (the period) can’t be first or last 0 can’t be first with repetition allowed = 2  4  4  3 without repetition allowed = 2  2  2  1 (first column, then last column, then middle two) note – extra rule without repetition – do first slot, then last slot, then 2nd slot then 3rd slot (because of limit on last) For the “extra rules”- let’s assume a PIN can contain a period in addition to digits, but because it would make it hard to read let’s assume the period can’t appear at the beginning or the end (first or last) in the PIN. Then the two cases are let’s assume the PIN can contain two periods (“with repetition”) or only one (“without repetition”).

7 Permutations Number of ways to arrange n different objects
Pick first object n ways Pick second object n-1 ways Pick third object n-2 ways Etc. Pick nth object 1 way n(n-1)(n-2)…1 = n! {a,b,c,d} linear permutations: abcd,acbd,bacd,bcad,cabd,cbad, abdc,acdb,badc,bcda,cadb,cbda, circular permulations: a-b-c-d, a-b-d-c,a-c-b-d,a-c-d-b,a-d-b-c,a-d-c-b

8 r-Permutations Number of ways to arrange r different objects out of n
Pick first object n ways Pick second object n-1 ways Pick third object n-2 ways Etc. Pick rth object n-r+1 ways n(n-1)(n-2)…(n-r+1) = {a,b,c,d} linear permutations: abcd,acbd,bacd,bcad,cabd,cbad, abdc,acdb,badc,bcda,cadb,cbda, circular permulations: a-b-c-d, a-b-d-c,a-c-b-d,a-c-d-b,a-d-b-c,a-d-c-b

9 Combinations Problem: Choose r objects out of n (order does not matter). Solution: First choose r objects out of n (order does matter). Then divide by number of orderings of r objects. Select 2 = {{AB}{AC}{AD}{BC}{BD}{CD}} 4!/(2!2!) = 4*3*2/(2*2)= 6 Select 3 = {{ABC}{ABD}{ACD}{BCD}} 4!/(3!1!) = 4*3*2/3*2 = 4 Another example if there is time The word “mathematically”- 14! ways to arrange. But there are three a’s and two t’s and two m’s and two l’s- divide by the number of different ways (which a or t or m or l you could be using).

10 Permutations with Indistinguishable Items I
Example: Assume you have a set of 15 beads: 6 green 4 orange 3 red 2 black How many permutations? Select positions of the green ones, then the orange ones, then the red ones, then the black ones. C(15,3) = 15!/(3!(15-3)!) = 15!/3!12! – selects the positions for the 3 red beads C(12,2) = 12!/(2!(12-2)!) = 12!/2!10! – selects the positions for the 2 black beads, etc show the canceling Another example if time How many 5 letter words can I make from the letters in “house”=5! How many 5 letter words can I make from “aaahk” 5! but then the aahka made with the 1st, 2nd and 3rd a doesn’t look different from the aahka made with the 3rd, 2nd and 1st a so how many of those are there (3!) because it is every permutation of the three a’s so there are 5!/3! possibilities (the 1!1! gets added by the formula and doesn’t change things because 1!=1 How many 5 letter words can I make from the letters of kooky 5! but can’t distinguish the k’s so 2! and can’t distinguish the o’s so another 2! 5!/(2!2!)

11 Permutations with Indistinguishable Items II
Example: Assume you have a set of 15 beads: 6 green 4 orange 3 red 2 black How many permutations? Take all permutations. Divide by the number of permutations of the green ones, then the orange ones, then the red ones, then the black ones. C(15,3) = 15!/(3!(15-3)!) = 15!/3!12! – selects the positions for the 3 red beads C(12,2) = 12!/(2!(12-2)!) = 12!/2!10! – selects the positions for the 2 black beads, etc show the canceling Another example if time How many 5 letter words can I make from the letters in “house”=5! How many 5 letter words can I make from “aaahk” 5! but then the aahka made with the 1st, 2nd and 3rd a doesn’t look different from the aahka made with the 3rd, 2nd and 1st a so how many of those are there (3!) because it is every permutation of the three a’s so there are 5!/3! possibilities (the 1!1! gets added by the formula and doesn’t change things because 1!=1 How many 5 letter words can I make from the letters of kooky 5! but can’t distinguish the k’s so 2! and can’t distinguish the o’s so another 2! 5!/(2!2!)

12 Permutations with Indistinguishable Items
Example: Permutations of “revere” C(15,3) = 15!/(3!(15-3)!) = 15!/3!12! – selects the positions for the 3 red beads C(12,2) = 12!/(2!(12-2)!) = 12!/2!10! – selects the positions for the 2 black beads, etc show the canceling Another example if time How many 5 letter words can I make from the letters in “house”=5! How many 5 letter words can I make from “aaahk” 5! but then the aahka made with the 1st, 2nd and 3rd a doesn’t look different from the aahka made with the 3rd, 2nd and 1st a so how many of those are there (3!) because it is every permutation of the three a’s so there are 5!/3! possibilities (the 1!1! gets added by the formula and doesn’t change things because 1!=1 How many 5 letter words can I make from the letters of kooky 5! but can’t distinguish the k’s so 2! and can’t distinguish the o’s so another 2! 5!/(2!2!)

13 Combinations with repetition
How many combinations of 20 A's, B's, and C's can be made with unlimited repetition allowed? Examples: 10 A’s, 7 B’s, 3 C’s; 20 A’s, 0 B’s, 0 C’s; 14 A’s, 0 B’s, 6 C’s. Reformulate as how may nonnegative solutions to without rep = (4 choose 3) = 4!/3!1! = 4 {abc}{abd}{acd}{bcd} with repetition [a,b,c][a,b,d][a,c,d][b,c,d] [a,a,a][a,a,b][a,a,c][a,a,d] [b,b,b][b,b,a][b,b,c][b,b,d] [c,c,c][c,c,a][c,c,b][c,c,d] [d,d,d][d,d,a][d,d,b][d,d,c] n categories (the letters a,b,c,d) -- r indistinguishable items (x’s that count how many of each) (r+(n-1))! / r! (n-1)! a | b| c | d xx| | x| = [a,a,c] x | x | x | = [a,b,c] xxx| | | = [a,a,a] connects to permutations with indistinguishable items because looking at number of words made from the X’s and the |’s number of categories –1 = # of |’s because the |’s are dividing lines number of X’s = size of the multiset because the X’s are yeses for who is in ANOTHER EXAMPLE Assume I will assign grades A,B,C,D,F to the class of 3 students, how many ways to assign those grades (3+5-1)!/3!(5-1)!=7!/3!4!=7*6*5/3*2=7*5 =35 But this assumes the 3 students are identical 5 – all three same grade 20 – 2 of 1 grade and 1 of another 10 – three different grades If students are different need to take combinations of each the 5 where they are all the same grade do not change the 20 where there is 2 of 1 and 1 of antoher, (3 choose 1) multiplied because need to select the 1 different one so there are 60 here the 10 where they are all different need to be mulitplied by 3! because there are 3! arrangements of 3 people so there are 60 here too this gives a total of 125 One last example: lets say just giving one of 5 grades to each of 3 different people 5*5*5 = 125 also

14 Solve in class Generalize
The number of nonnegative integer solutions of the equation The number of selections, with repetition, of size r from a collection of size n. The number of ways r identical objects can be distributed among n distinct containers. Say why it’s relevant to the problem. (4) x+y = =1+2 =2+1= (10) x+y+z = =0+3+0=3+0+0 =1+2+0=2+1+0=1+0+2=2+0+1=0+1+2=0+2+1 =1+1+1 (5) x+y= =1+3= x+y+z= = = =0+4= =1+1+2=1+2+1=2+1+1 =0+1+3=0+3+1=1+0+3=1+3+0=3+0+1=3+1+0 = 2+2+0=2+0+2=0+2+2 (r + (n-1))! r!(n-1)! Solve in class

15 Choosing r elements out of n elements
order matters order doesn’t matter repetition allowed repetition not allowed

16 Where the multiplication rule doesn’t work
People= {Alice, Bob, Carolyn, Dan} Need to be appointed as president, vice-president, and treasurer, and nobody can hold more than one office how many ways can it be done with no restrictions? how many ways can it be done if Alice doesn’t want to be president? how many ways can it be done if Alice doesn’t want to be president, and only Bob and Dan are willing to be vice- president? tree president level has B, C and D vp level has B—D, C—B&D, D—B trreasurer level has D—A&C, B—A&D, D—A&B, B—A&C

17 Harder examples of selecting representatives
Candidates= {Azar, Barack, Clinton, Dan, Erin, Fred} Select two, with no restrictions Select two, assuming that Azar and Dan must stay together Select three, with no restrictions Select three, assuming that Azar and Dan must stay together Select three, assuming that Barack and Clinton refuse to serve together select 2 – n = 6, r = 2 – C(6,2) = 6!/(2!4!) = 6*5/2 = 3*5 = 15 select 2 with couple – sets with A&B + sets without A&B = 1 + C(4,2) = 1+6 = 7 select 3 – n=6, r=3 – C(6,3) = 20 select 3 with couple restriction = [Sets with A&B = C(4,1)] + [sets without (A or B) = C(4,3)] = 4+4 = 8 select 3 after break up of the couple = [sets with A (not B) = C(4,2)]+[sets with B (not A) = C(4,2)]+[sets with neither A nor B=C(4,3)] = 16

18 Properties of combinations and their proofs
n choose 0 = n!/[0!(n-0)!]=n!/1*n!=n!/n!=1 n choose 1 = n!/[1!(n-1)!] = n!/(n-1)!= n(n-1)!/(n-1)! = n n choose 2 = n!/[2!(n-2)!] = [n*n-1*(n-2)!]/[2*(n-2)!]=n(n-1)/2 n choose r = n!/[r!(n-r)!] n choose (n-r) = n!/[(n-r)!(n-(n-r))!] = n!/[(n-r)!r!]

19 A Combinatorial Identity
How many subsets are there of {1,2, …, n}? Solution I: 1 in or out, 2 in or out, …, n in or out: Hence Solution II: Can CHOOSE set with 0 elements, or 1 element, or …, or n elements: Hence tree president level has B, C and D vp level has B—D, C—B&D, D—B trreasurer level has D—A&C, B—A&D, D—A&B, B—A&C

20 The binomial theorem

21 Different types of members
{Alice, Bob, Carol, Dan, Erin, Fred, George, Harry} Suppose Alice, Carol, and Erin are MATH majors, and the rest are CS majors. 8 people in the set: 3 MATHs & 5 CSs make a 5-member team of 2 MATHs and 3 CSs make a 5-member team that has only one MATH make a 5-member team that has no MATHs make a 5-member team that has at least one MATH

22 Probability The likelihood of a specific event.
Sample space = set of all possible outcomes Event = subset of sample space Equal probability formula: given a finite sample space S where all outcomes are equally likely select an event E from the sample space S the probability of event E from sample space S: Connect this back to the number of 3 digit integers divisible by 5 (or the other example of divisible by 3) and what is the probability of randomly selecting a number divisible by 5 if you randomly select a 4 digit integer P(E) = 180/900 = 18/90 = 2/10 = 1/5

23 Examples of Sample Spaces
Two coins sample space = {(H,H), (H,T), (T,H), (T,T)} Cards values: 2,3,4,5,6,7,8,9,10,J,Q,K,A suits: D(), H(), S(), C() Dice sample space {(1,1),(1,2),(1,3),(1,4),(1,5),(1,6), (2,1),(2,2),(2,3),(2,4),(2,5),(2,6), (6,1),(6,2),(6,3),(6,4),(6,5),(6,6)} Note: probability & actual outcomes often differ Probability of no heads Probability of at least one head Probability of same sides on the two coins P(no H) = ¼ = 25% = 1:4 p(at least one) = 3/4 = 75% = 3:4 p(same) = 2/4 = 50% = 2:4 = 1:2 probability of drawing the Ace of Spades probability of drawing a Spade probability of drawing a face card probability of drawing a red face card P(A of S) = 1/52 P(S) = 13/52 = ¼ P(F) = 12/52 = 3/13 P(RF) = 6/52 = 3/26 Probability of rolling a 10 Probability of rolling a pair 10’s = {(4,6),(5,5),(6,4)} P(10) = 3/36 = 1/12 pairs = {(1,1),(2,2),(3,3),(4,4,),(5,5),(6,6)} P(pair) = 6/36 = 1/6

24 Probabilities with PINs
Number of four letter PINs of {a,b,c,d} with repetition allowed = 4  4  4  4 = 256 with no repetition allowed = 4  3  2  1 = 24 What is the probability that your 4 digit PIN has no repeated digits? What is the probability that your 4 digit PIN does have repeated digits? Tree method: 4(144 + 3(24 + 23)) P(no Repeated) = 24/256 P(Repeated) = 1-(24/256)

25 Probability of Poker Hands
Straight Flush Four of a kind Full house Flush Straight Three of a kind Two pairs Pair Nothing Connect this back to the number of 3 digit integers divisible by 5 (or the other example of divisible by 3) and what is the probability of randomly selecting a number divisible by 5 if you randomly select a 4 digit integer P(E) = 180/900 = 18/90 = 2/10 = 1/5 Solve in class

26 Multi-level probability
If a coin is tossed once, the probability of head = ½ If it’s tossed 5 times the probability of all heads: the probability of exactly 4 heads: This is because the coin tosses are all independent events People are suspicious of results which seem too unlikely.

27 Tournament play Team A and Team B compete in a “best of 3” tournament
They each have an equal likelihood of winning each game Do the leaves add up to 1? Do they always have to play 3 games? What's the probability the tournament finishes in 2 games? Do A and B have an equal chance of winning?

28 What if A wins each game with prob 2/3?
Each line for A must have a 2/3 Each line for B must have a 1/3 How likely is A to win the tournament? How likely is B to win the tournament? What is the probability the tournament finishes in two games? P(A) = 4/9 + 4/27 + 4/27 = 12/27+4/27+4/27 = 20/27 P(B) = 1/9+2/27+2/27= 3/27+2/27+2/27=7/27


Download ppt "Counting and Probability"

Similar presentations


Ads by Google