Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 6, Counting and Probability

Similar presentations


Presentation on theme: "Chapter 6, Counting and Probability"— Presentation transcript:

1 Chapter 6, 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 divisible by something
How many positive three-digit integers are there? (this means only the ones that require 3 digits) 999 – = 900 How many three-digit integers are divisible by 5? think about the definition of divisible by x | y  ( k Z)[y = kx] then count the k’s that work 100, 101, 102, 103, 104, 105, 106,…,994, 995, 996, 997, 998, 999 20   …  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 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

5 Coins and cards and dice
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

6 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.

7 The breakfast problem Suppose your cereal can be Rice Krispies, cornflakes, Raisin Bran, or Cheerios. Suppose your drink can be coffee, orange juice, or milk. How many ways can you have breakfast?

8 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 n1n2  ∙ ∙ ∙  nk ways Cartesian product n(A)=3, n(B)=2, n(C)=4 n(A  B  C) = 24 n(A  B) = 6 n((A  B)  C) = 24

9 Discrete Structures CMSC 250 Lecture 34
April 21, 2008 9

10 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 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”).

11 Probabilities with PINs
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 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? Probability of the complement of an event P(E’) = P(Ec) = 1  P(E) P(no Repeated) = 24/256 P(Repeated) = 1-(24/256)

12 The difference rule formally
If A is a finite set and B  A, then n(A B) = n(A) – n(B) One application: probability of the complement of an event: P(E’) = P(Ec) = 1  P(E)

13 PINs with less specified length- addition rule
Assume a PIN can be of length 2, 3, or 4, using {0,1,2,.} Partition the problem: number of length-2 PINs w/rep allowed: 4  4 = 16 number of length-3 PINs w/rep allowed: 4  4  4 = 64 number of length-4 PINs w/rep allowed: 4  4  4  4 = 256 Number of PINs if allowing length 2, 3, or 4 = 336

14 The addition rule formally
If A1  A2  A3 …  Ak = A and A1, A2 , A3,…,Ak are pairwise disjoint in other words, if these subsets form a partition of A, then n(A) = n(A1) + n(A2) + n(A3) + ∙∙∙ + n(Ak) Another example for Multiplication Rule and Addition Rule *** How many 3 digit integers are divisible by 5? How many end in a 0? 9*10*1 = 90 How many end in a 5? 9*10*1 = 90 These form a partition with the set of numbers divisible by 5 so = 180

15 The inclusion/exclusion rule
If there are two sets: n(A  B) = n(A) + n(B) – n(A  B) If there are three sets: n(A  B  C) = n(A) + n(B) + n(C) – n(A  B) – n(A  C) – n(B  C) + n(A  B  C) Number of 3 digit integers that are multiples of 3 or 5??? n(A union B) Number of multiples of 3 = = 300 = n(A) Number of multiples of 5 = = 180 = n(B) Number of multiples of 3&5 = Number of multiples of 15 = = 60 = n(A intersect B) Number of multiples of 3 or 5 = = 420 = n(A union B)

16 Discrete Structures CMSC 250 Lecture 35
April 23, 2008 16

17 Permutations Different ways of arranging all n of n objects
in either a line or a circle without duplication/all items distinguishable note: order is taken into account Number of linear permutations of N objects = N! N possible for 1st position  (N – 1) for 2nd  ∙ ∙ ∙  1 for last Number of circular permutations of N objects = (N  1)! Fix one person, then (N – 1) possible for next position * (N – 2) for 2nd  ∙ ∙ ∙  1 for last {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

18 r-permutations If there are n things in a set, and you want to line up only r of them Example: Class = {Alice, Bob, Carol, Dan} select a president and a vice president to represent the class select a president, vice president, and webmaster {a,b,c,d} P(4,2) = 4!/(4-2)! = 24/2 = 12 = ab,ac,ad,ba,bc,bd,ca,cb,cd,da,db,dc P(4,3) = 4!/(4-3)! = 24/1 = 24= abc,abd,acb,acd,adb,adc, bac,bad,bca,bcd,bda,bdc, cab,cad,cba,cda,cbd,cdb, dac,dab,dba,dbc,dca,dcb P(4,1) = 4!/(4-1)! = 4!/3! = 24/6 = 4 = a,b,c,d P(7,5) = 7!/(7-5)!=7!/2!=7*6*5*4*3 P(7,2) = 7!/(7-2)! = 7!/5!=7*6

19 Combinations Different ways of selecting objects
counting subsets without duplication/all items distinguishable note: order is not taken into account Examples: suppose {Alice, Bob, Carol, Dan} are on the ballot select two superdelegates select three superdelegates 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).

20 Permutations but of indistinguishable items
Examples: Arrangements of the word “baboons” Assume you have a set of 15 beads: 6 green 4 orange 3 red 2 black select positions of the green ones, then the orange ones, then the red ones, then the black ones (or a different order of selecting their positions would work as well) 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!)

21 Discrete Structures CMSC 250 Lecture 36
April 25, 2008 21

22 Combinations with repetition
{a,b,c,d,e} How many 3-combinations can be made without repetition? How many 3-combinations can be made with unlimited repetition allowed? These are multisets [a,b,c] not sets {a,b,c} and not tuples (a,b,c) How many combinations of 20 a's, b's, and c's can e made with unlimited repetition allowed? 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

23 Notice similarities 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)!

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

25 Probability with combinations
Assume: there are 32 people in a class seven will be chosen to get extra homework What is the probability that you get extra homework? Number of ways to select the lucky seven Number of ways to select if you get homework P(you get homework) “lucky 7” = (32 choose 7) “I get HW” = (31 choose 6) P(I get HW) = (31 choose 6) / (32 choose 7) = invert and multiply gives 7/32? another example if time Urn of 9 balls – three colors – probability that if I draw 3 at the same time that I will have one of each color total number of draws = (9 choose 3) = 9!/(3!6!)=84 assume the balls are split 5 red, 1 blue and 3 yellow total number of draws where I get one of each color = (5 choose 1)(1 choose 1)(3 choose 1) = 15 P (one of each color) = 15/84=5/26 b) assume the balls are split with 3 red, 3 blue and 3 yellow ways to draw one of each color = (3 choose 1)(3 choose 1)(3 choose 1) = 27 P(one of each color) = 27/84 = 9/26

26 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?

27 What if A wins 2 of every 3 games?
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

28 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

29 Discrete Structures CMSC 250 Lecture 37
April 28, 2008 29

30 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

31 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!]

32 The binomial theorem

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


Download ppt "Chapter 6, Counting and Probability"

Similar presentations


Ads by Google