Chapter 6, Counting and Probability

Slides:



Advertisements
Similar presentations
Main Menu Main Menu (Click on the topics below) Combinations Example Theorem Click on the picture.
Advertisements

1 Counting. 2 Situations where counting techniques are used  You toss a pair of dice in a casino game. You win if the numbers showing face up have a.
Counting and Probability The outcome of a random process is sure to occur, but impossible to predict. Examples: fair coin tossing, rolling a pair of dice,
Multiplication Rule. A tree structure is a useful tool for keeping systematic track of all possibilities in situations in which events happen in order.
Discrete Structures Chapter 4 Counting and Probability Nurul Amelina Nasharuddin Multimedia Department.
Discrete Structures Chapter 4 Counting and Probability Nurul Amelina Nasharuddin Multimedia Department.
Counting II: Recurring Problems And Correspondences Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 10Feb 12, 2004Carnegie.
Discrete Mathematics Lecture 7 More Probability and Counting Harper Langston New York University.
Basics of Probability. Trial or Experiment Experiment - a process that results in a particular outcome or “event”. Simple event (or sample point), E i.
1 Section 5.1 Discrete Probability. 2 LaPlace’s definition of probability Number of successful outcomes divided by the number of possible outcomes This.
Discrete Mathematics Lecture 5
Discrete Mathematics Lecture 6 Alexander Bukharovich New York University.
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
LING 438/538 Computational Linguistics Sandiway Fong Lecture 17: 10/24.
Copyright © Cengage Learning. All rights reserved. CHAPTER 9 COUNTING AND PROBABILITY.
Class notes for ISE 201 San Jose State University
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProbability.
4. Counting 4.1 The Basic of Counting Basic Counting Principles Example 1 suppose that either a member of the faculty or a student in the department is.
Counting Principles (Permutations and Combinations )
5.1 Basic Probability Ideas
Review of 5.1, 5.3 and new Section 5.5: Generalized Permutations and Combinations.
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 6 Counting and Probability Instructor: Hayk Melikyan Today we will review sections 6.4,
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Topics to be covered: Produce all combinations and permutations of sets. Calculate the number of combinations and permutations of sets of m items taken.
Generalized Permutations and Combinations
Counting and Probability. Counting Elements of Sets Theorem. The Inclusion/Exclusion Rule for Two or Three Sets If A, B, and C are finite sets, then N(A.
Copyright ©2006 Brooks/Cole A division of Thomson Learning, Inc. Introduction to Probability and Statistics Twelfth Edition Chapter 4 Probability and Probability.
9.3 Addition Rule. The basic rule underlying the calculation of the number of elements in a union or difference or intersection is the addition rule.
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
Section 2.6: Probability and Expectation Practice HW (not to hand in) From Barr Text p. 130 # 1, 2, 4-12.
You probability wonder what we’re going to do next!
March 10, 2015Applied Discrete Mathematics Week 6: Counting 1 Permutations and Combinations How many different sets of 3 people can we pick from a group.
3. Counting Permutations Combinations Pigeonhole principle Elements of Probability Recurrence Relations.
1 Lecture 4 (part 1) Combinatorics Reading: Epp Chp 6.
Lesson Counting Techniques. Objectives Solve counting problems using the Multiplication Rule Solve counting problems using permutations Solve counting.
Objectives Solve counting problems using the Multiplication Rule Solve counting problems using permutations Solve counting problems using combinations.
September1999 CMSC 203 / 0201 Fall 2002 Week #9 – 21/23/25 October 2002 Prof. Marie desJardins.
Chapter 2: Probability · An Experiment: is some procedure (or process) that we do and it results in an outcome. A random experiment: is an experiment we.
Copyright © 2006 Brooks/Cole, a division of Thomson Learning, Inc. Sets and Counting6 Sets and Set Operations The Number of Elements in a Finite Set The.
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 6 Counting and Probability Instructor: Hayk Melikyan Today we will review sections 6.1,
Copyright © 2006 Brooks/Cole, a division of Thomson Learning, Inc. Sets and Counting6 Sets and Set Operations The Number of Elements in a Finite Set The.
Natural Language Processing Giuseppe Attardi Introduction to Probability IP notice: some slides from: Dan Jurafsky, Jim Martin, Sandiway Fong, Dan Klein.
Discrete Mathematics Lecture # 25 Permutation & Combination.
Discrete Mathematics, 1st Edition Kevin Ferland Chapter 6 Basic Counting 1.
Counting II: Recurring Problems And Correspondences Great Theoretical Ideas In Computer Science John LaffertyCS Fall 2005 Lecture 7Sept 20, 2005Carnegie.
Main Menu Main Menu (Click on the topics below) Combinatorics Introduction Equally likely Probability Formula Counting elements of a list Counting elements.
Counting Principles Multiplication rule Permutations Combinations.
+ Chapter 5 Overview 5.1 Introducing Probability 5.2 Combining Events 5.3 Conditional Probability 5.4 Counting Methods 1.
Spring 2016 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University.
Counting II: Recurring Problems And Correspondences Great Theoretical Ideas In Computer Science V. AdamchikCS Spring 2006 Lecture 6Feb 2, 2005Carnegie.
Spring 2016 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University.
CS Lecture 8 Developing Your Counting Muscles.
5.5 Generalized Permutations and Combinations
2/24/20161 One, two, three, we’re… Counting. 2/24/20162 Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter.
3/7/20161 Now it’s time to look at… Discrete Probability.
Week 9 - Friday.  What did we talk about last time?  Partial orders  Total orders  Basic probability  Event  Sample space  Monty Hall  Multiplication.
13 Lesson 1 Let Me Count the Ways Fundamental Counting Principle, Permutations & Combinations CP Probability and Statistics FA 2014 S-ID.1S-CP.3S-CP.5.
Section 6.3. Section Summary Permutations Combinations.
Counting and Probability
Discrete Mathematics Lecture 8 Probability and Counting
Developing Your Counting Muscles
9. Counting and Probability 1
CS100: Discrete structures
COUNTING AND PROBABILITY
First lecture fsalamri Faten alamri.
Counting II: Recurring Problems And Correspondences
Discrete Structures Counting.
Now it’s time to look at…
Counting Elements of Disjoint Sets: The Addition Rule
Presentation transcript:

Chapter 6, Counting and Probability 1

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

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 – 100 + 1 = 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 21  5 … 199  5 count the integers between 20 and 199 199 – 20 + 1 = 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 11-4+1 = 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+1  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

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

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

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.

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?

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

Discrete Structures CMSC 250 Lecture 34 April 21, 2008 9

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

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)

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)

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

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 90 + 90 = 180

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 = 333-34+1 = 300 = n(A) Number of multiples of 5 = 199-20+1 = 180 = n(B) Number of multiples of 3&5 = Number of multiples of 15 = 66-7+1 = 60 = n(A intersect B) Number of multiples of 3 or 5 = 300+180-60 = 420 = n(A union B)

Discrete Structures CMSC 250 Lecture 35 April 23, 2008 16

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

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

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

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!)

Discrete Structures CMSC 250 Lecture 36 April 25, 2008 21

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

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 = 3 0+3=1+2 =2+1=3+0 (10) x+y+z = 3 0+0+3=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=4 2+2=1+3=3+1 x+y+z=4 0+0+4=4+0+0+0+4+0= =0+4=4+0 =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)!

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

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

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?

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

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

Discrete Structures CMSC 250 Lecture 37 April 28, 2008 29

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

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

The binomial theorem

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