290 likes | 501 Views
ENGG2012B Lecture 14 Counting & Probability. Kenneth Shum. BASIC COUNTING FUNCTIONS. N factorial. http://en.wikipedia.org/wiki/Factorial. 4 people form a queue randomly. How many different patterns can we observe? There are four combinations for the first position.
E N D
ENGG2012BLecture 14Counting & Probability Kenneth Shum ENGG2012B
BASIC COUNTING FUNCTIONS ENGG2012B
N factorial http://en.wikipedia.org/wiki/Factorial • 4 people form a queue randomly. How many different patterns can we observe? • There are four combinations for the first position. • After the first person has arrived, there are three combinations for the second position. • After the first and second persons have arrived, there are two combinations for the third position. • Now, the last person is unique determined. • Answer = (4)(3)(2)(1) = 24. • Notations: n! = (n)(n-1)(n-2)…(3)(2)(1). • If we expand an nxn determinant, the number of terms is precisely n!. ENGG2012B
4! = 24 • The 24 permutations of 1,2,3,4 in lexicographical order (a.k.a the “dictionary order”) : 1234, 1243, 1324, 1342, 1423, 1432, 2134, 2143, 2314, 2341, 2413, 2431, 3124, 3142, 3214, 3241, 3412, 3421, 4123, 4132, 4213, 4231, 4312, 4321. ENGG2012B
Falling factorial http://en.wikipedia.org/wiki/Pochhammer_symbol • 5 people enter a queue in a random manner, and the queue size is only 3. How many different patterns can we observe? • There are five combinations for the first position. • After the first person has arrived, there are four combinations for the second position. • After the first and second persons have arrived, there are three combinations for the third position. • Answer = (5)(4)(3) = 60. • Notation: (n)k = (n)(n-1)(n-2)…(n-k+1). • (n)k is called the “falling factorial”, the “Pochhammer symbol”, or “descending factorial”. • When k=n, (n) n reduces to n!. ENGG2012B
(5)3 = 60 • The 60 combinations in lexicographical order 123, 124, 125, 132, 134, 135, 142, 143, 145, 152, 153, 154, 213, 214, 215, 231, 234, 235, 241, 243, 245, 251, 253, 254, 312, 314, 315, 321, 324, 325, 341, 342, 345, 351, 352, 354, 412, 413, 415, 421, 423, 425, 431, 432, 435, 451, 452, 453, 512, 513, 514, 521, 523, 524, 531, 532, 534, 541, 542, 543. ENGG2012B
Counting when order is irrelevant • In how many ways can we choose 2 ice-cream toppings out of 10 ice-cream toppings? • Let’s call the 10 toppings A to J. • There are 45 choices: AB, AC, AD, AE, AF, AG, AH, AI, AJ, BC, BD, BE, BF, BG, BH, BI, BJ, CD, CE, CF, CG, CH, CI, CJ, DE, DF, DG, DH, DI, DJ, EF, EG, EH, EI, EJ, FG, FH, FI, FJ,GH, GI, GJ, HI, HJ, IJ. ENGG2012B
Binomial coefficient http://en.wikipedia.org/wiki/Binomial_coefficient • We use the symbol to stand for the number of ways we can choose k objects out of n distinguishable objects. • Example: • It is pronounced as “n choose k”. • Other notations : nCk, Cnk ENGG2012B
Derivation of binomial coeff. • Let the number of ways that k objects are chosen from n objects be x. • Count the number of ways to pick k objects from n objects with order, e.g. ABC is regarded as different from BCA. • There are two different ways to count. • We already know that there are (n)k ways. • We first pick k objects without order. There are x choices by assumption. Then we choose one of the k! possible orders. • Therefore (n)k = x k! x = (n)k/ k! ENGG2012B
Model of Balls and Bins • Throw k balls into n bins. The n bins are distinguishable • The balls may be distinguishable or indistinguishable. • There may be at most one ball per bin, or no such restriction. • Task: Count the total number of combinations in each case 1 2 3 4 5 6 ENGG2012B
May be more than one ball per bin • Throw k balls into n bins. The n bins are distinguishable • Balls are distinguishable • Balls are indistinguisable 5 1 3 4 2 1 2 3 4 5 6 1 2 3 4 5 6 ENGG2012B
At most one ball per bin • Balls are distinguishable • Balls are indistinguishable 5 1 3 4 2 1 2 3 4 5 6 1 2 3 4 5 6 ENGG2012B
Throwing k Balls into n Bins ENGG2012B
Occupancy problem http://en.wikipedia.org/wiki/Occupancy_theorem • The number on the lower right corner of the table is the solution to the so called occupancy problem. • Example: n=3, k = 2. There are 6 combinations ENGG2012B
A useful trick 0 | 0 | To count the number of ways that we can throw k indistinguishable balls into n bins, we use n-1 vertical bars to separate the k balls. | 0 | 0 0 | | 0 00 | | The question reducesto counting the numberof combinations ofchossing n-1 objectsout of k+n-1 objects. | 0 0 | | | 0 0 ENGG2012B
黑版上排列組合 ENGG2012B
The questions on the board • Paint the faces of a cube by six different colours, so that each face has one and only one colour. How many different ways can we paint the cube? • There are eight persons and six different types of drinks. Each person want to buy one drink. In how many ways can they purchase? • There are five beads of different colours. In how many ways can we put them together to form a bracelet? C B A 1 2 5 3 4 ENGG2012B
PROBABILITY VIA COUNTING ENGG2012B
Terminologies • The end result of a random experiment is called an outcome. • A random experiment may be throwing a pair of dice, or checking whether it is sunny or raining today. • The set of all possible outcomes is called the sample space of the random experiment. • Each element in the sample space is an outcome. • We usually use the Greek letter for the sample space. • An event is a set of outcomes. • A probability measure assigns a real number to each event. • The probability of an event E is denoted by Pr(E). ENGG2012B
Venn diagram Sample space = {1, 2, 3, 4, 5} 4 2 3 1 5 Event E2 Event E1 E1 = {1,3} E2 = {2, 3, 5} E1c= {2, 4, 5} E2c= {1, 4} Superscript c stands for set complement. ENGG2012B
Union and intersection Sample space = {1, 2, 3, 4, 5} 4 2 3 1 5 Event E2 Event E1 E1 E2 = {1, 2, 3, 4, 5} A sample is in the union of E1 and E2 if and onlyif it is in E1or in E2. • stands for set union. • stands for set intersection. E1 E2 = {3} A sample is in the intersection of E1 and E2 if and only if it is in E1and in E2. ENGG2012B
Example 1: Coin flipping • Toss a fair coin 2n times (where n is a positive integer). • What is the probability that there are exactly n heads? ENGG2012B
Example 2: lucky draw • Find the probability of • Prize A • Prize B • Prize C • Prize A and B • Prize A and C • Prize B and C • Prize A and B and C • Prize A or B • Prize A or C • Prize B or C • Prize A or B or C • No prize • There are 50 ping-pong balls in a box. They are numbered from 1 to 50. • Draw one ball from the box. You get • prize A if the number is even, • prize B if the number is a multiple of 3, • prize C is if the number is a multiple of 5. ENGG2012B
Principle of inclusion-exclusion • For any two events E1 and E2, we have Pr(E1 E2) = Pr(E1) + Pr(E2) – Pr(E1 E2) • For any three events E1, E2 and E3, we have Pr(E1 E2 E3) = Pr(E1) + Pr(E2) + Pr(E3) – Pr(E1 E2) – Pr(E1 E3) – Pr(E2 E3) +Pr(E1 E2 E3). ENGG2012B
Example 3: football victory problem The funny name is due to the book “Concrete mathematics” • n people are watching a football game. Each of them wears a hat. At the end of the game they throw their hats to the air, and pick up a hat at random. What is the probability that at least one of them get back his own hat? The problem is equivalent to counting the total number of derangements. A derangement is a permutation of n objects such that none of the objectappears in the original position. ENGG2012B