Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 COMP2121 Discrete Mathematics Principle of Inclusion and Exclusion Probability Hubert Chan (Chapters 7.4, 7.5, 6) [O1 Abstract Concepts] [O3 Basic Analysis.

Similar presentations


Presentation on theme: "1 COMP2121 Discrete Mathematics Principle of Inclusion and Exclusion Probability Hubert Chan (Chapters 7.4, 7.5, 6) [O1 Abstract Concepts] [O3 Basic Analysis."— Presentation transcript:

1 1 COMP2121 Discrete Mathematics Principle of Inclusion and Exclusion Probability Hubert Chan (Chapters 7.4, 7.5, 6) [O1 Abstract Concepts] [O3 Basic Analysis Techniques]

2 2 Review Principle of Inclusion-Exclusion Given two sets A 1 and A 2, what is | A 1  A 2 | ? | A 1  A 2 | = | A 1 | + | A 2 |  | A 1  A 2 | Given three sets A 1, A 2 and A 3, what is | A 1  A 2  A 3 | ? | A 1  A 2  A 3 | = |A| + |B| + |C| - |A  B| - |B  C| - |A  C| + |A  B  C| For a general integer n>0, what is | A 1  A 2  …  A n | ? A1A1 A2A2

3 3 Principle of Inclusion and Exclusion Let A i be the subset of elements with property P i Let be the universal set. By De Morgan’s Law, A1A1 A2A2 A3A3

4 4 Compact Form [n] = {1,2,3,…,n}   = Universal Set = For subset S of [n], A S =

5 5 Suppose a student wants to make up a schedule for a 7-day period during which she will study one subject each day. She is taking 4 subject: mathematics, physics, chemistry, and economics. What is the number of possible schedules that devote at least one day to each subject? Let A1 be the no. of schedules that do not contain math (P1). A2 be the no. of schedules that do not contain physics (P2). A3 be the no. of schedules that do not contain chemistry (P3). A4 be the no. of schedules that do not contain economics (P4). Ans: 4 7 - |A1  A2  A3  A4| |A1| = |A2| = |A3| = |A4| = 3 7. |A1  A2| = |A1  A3| = |A1  A4| = |A2  A3| = |A2  A4| = |A3  A4| = 2 7. |A1  A2  A3| = |A1  A2  A4| = |A1  A3  A4| = |A2  A3  A4| = 1 7. |A1  A2  A3  A4| = 0. Ans: 4 7 - 4(3 7 ) + 6(2 7 ) - 4 (1 7 ) + 0. |A1  A2  A3  A4| = 4(3 7 ) – 6(2 7 ) + 4 (1 7 ) – 0.

6 6 More examples Number of solutions for x 1 + x 2 + x 3 = 13, when x 1, x 2, x 3 are nonnegative integers? Answer = C(13+3-1, 2) = C(15, 2) How about if x 1  1, x 2  2, x 3  3? It is the same as x’ 1 + x’ 2 + x’ 3 = 7. Answer: C(7+3-1, 2) = 36

7 7 Number of Solutions [O3] Number of solutions for x 1 + x 2 + x 3 = 13, with x 1  1, x 2  2, x 3  3, |A 0 |= C(7+3-1, 2) = 36 How about: Number of solutions for x 1 + x 2 + x 3 = 13, where 4  x 1  1, 3  x 2  2, x 3  3? A 1 : 4  x 1 is violated. Number of solutions with x 1  5, x 2  2, x 3  3, This reduces to solving x’ 1 + x’ 2 + x’ 3 = 3. Answer: |A 1 |= C(3+3-1, 2) = 10 A 2 : 3  x 2 is violated. Number of solutions with x 1  1, x 2  4, x 3  3, This reduces to solving x’ 1 + x’ 2 + x’ 3 = 5. Answer: |A 2 | = C(5+3-1, 2) = 21 Number of solutions x 1  5, x 2  4, x 3  3, (A 1  A 2 ) This reduces to solving x’ 1 + x’ 2 + x’ 3 = 1. Answer: |A 1  A 2 |= C(1+3-1, 2) = 3 Final Answer: |A 0 | - |A 1 | - |A 2 | + |A1  A2| = 36 - 10 – 21 + 3 = 8 A1A1 A2A2

8 8 Number of Solutions Number of solutions for x 1 + x 2 + x 3 + x 4 = 16, with x 1  1, x 2  2, x 3  3, x 4  0, |A 0 |= C(10+4-1, 3) = 286 How about: Number of solutions for x 1 + x 2 + x 3 + x 4 = 16, where 5  x 1  1, 4  x 2  2, 6  x 3  3, x 4  0? A 1 : 5  x 1 is violated. Answer: |A 1 |= C(5+4-1, 3) = 56 A 2 : 4  x 2 is violated. Answer: |A 2 | = C(7+4-1, 3) = 120 A 3 : 6  x 3 is violated. Answer: |A 3 | = C(6+4-1, 3) = 84 (A 1  A 2 ): x 1  6, x 2  5, x 3  3, x 4  0 Answer: |A 1  A 2 |= C(2+4-1, 3) = 10 (A 2  A 3 ): x 1  1, x 2  5, x 3  7, x 4  0 Answer: |A 2  A 3 |= C(3+4-1, 3) = 20 (A 1  A 3 ): x 1  6, x 2  2, x 3  7, x 4  0 Answer: |A 1  A 3 |= C(1+4-1, 3) = 4  (A 1  A 2  A 3 ): x 1  6, x 2  5, x 3  7, x 4  0:  Final Answer: |A 0 | - |A 1 | - |A 2 | - |A 3 | + | A 1  A 2 | + | A 2  A 3 | + | A 1  A 3 | - | A 1  A 2  A 3 | = 286 – 56 – 120 – 84 + 10 + 20 + 4 – 0 = 60

9 9 Probability [O1 Abstract Concepts] [O3 Basic Analysis Techniques]

10 10 Probability - The Prize is Right There are 3 doors, a grand prize is behind one of them. After you make your choice, the host always open a losing door from the other two. Will you change your mind and switch door? EMPTYEMPTY

11 11 Probability [O1] Sample space  – a set of possible outcomes; e.g. dice = {1, 2, 3, 4, 5, 6} Event – a subset of sample space; e.g., small numbers = {1, 2, 3} Probability of an event E, P(E) = |E| / |S| e.g. the probability that you throw a dice and it turns out to be even, is | { 2, 4, 6 } | / | { 1, 2, 3, 4, 5, 6} | = 0.5

12 12 Probability Sample space S = { ♠, ♥, ♦, ♣ } x {A, 2, 3, 4, 5, 6 7, 8, 9, T, J, Q, K} Event = { ♠ 9 }; Probability: P( { ♠ 9} ) = | { ♠ 9} | / |S| = 1 / 52 Event = a card of heart = { ♥ A, ♥ 2, ♥ 3, ♥ 4, ♥ 5, ♥ 6, ♥ 7, ♥ 8, ♥ 9, ♥ T, ♥ J, ♥ Q, ♥ K }. Probability: P( a card of heart ) = 13 / 52 Event = a red card ; P( a red card ) = 26 / 52

13 13 Probability Example: Probability when the sum of 2 rolled fair dice is 6 Solution1: |S| =6 2 = 36 outcomes E ={(1,5 ), (2,4), (3,3), (4,2), (5,1)} P(E) =|E| / |S| = 5/36 Solution2: S be the set of 2-combinations with repetition, |S| = C(6+2-1,2) = 21 E = {{1,5}, {2,4}, {3,3}} So P(E)= |E| / |S| = 3/21 = 1/7 P(E) = |E| / |S| with the assumption that all outcomes are equally likely. (correct?) Solution 1 is correct because all its outcomes are equally likely

14 14 Probability on Cards Example 1: Probability (a 5-card hand without a spade ace) |S| =C(52,5) = 52x51x50x49x48 / 5! |E 1 |=C(51,5) = 51x50x49x48x47 / 5! P(E 1 ) =|E 1 | / |S| = 47 / 52 Are all “combinations” equally probable? Why combinations? “Yes” - because all combinations can be obtained in 5! ways.

15 15 Probability on cards Ex 2: Probability (a 5-card hand without any ace) |E 2 |=C(48,5) = 48x47x46x45x44 / 5! |S| =C(52,5) = 52x51x50x49x48 / 5! P(E 2 ) = |E 2 | / |S| = C(48,5) / C(52,5) = (48/52) (47/51) (46/50) (45/49) (44/48) = 0.658842 Ex 3: Probability (a 5-card hand with two pairs) |E 4 |=C(13,2) · C(4,2)·C(4,2)·C(44,1) Which 2 ranks? Which 2 suits? Which remaining?

16 16 Card Game Puzzles Consider 7 cards of different face values from a pack of cards (no pairs) as below, BET a randomly picked card from the remaining pack will form a pair with one of the 7 cards? YES or NO LetP= probability that it will form a pair = (7 x 3) / (52 – 7) = 21 / 45 ANSWER : Bet NO

17 17 The Prize is Right [O3] There are 3 doors, a grand prize is behind one of them. After you make your choice, the host always open the losing door. Will you change your mind and switch door? EMPTYEMPTY

18 18 Will you switch door? No switch – chance of winning is 1/3 Switch – LOSE if your choice is originally correct; WIN if your choice is originally wrong. Since originally the probability of losing is 2/3, by switching door, the probability of winning will be 2/3.

19 19 Will you switch door? Another solution. Since no additional information is gained during the process, you can decide whether to switch or not at the beginning. A case study according to your first choice:  Suppose you choose the first door. If you do not switch, you win with probability 1/3. If you switch, you win with probability 2/3.  Suppose you choose the second or the third door. Similar analysis applies. Prize Behind1st door2nd door3rd door No switchWinLose SwitchLoseWin

20 20 Formal Definition [O1] 1.Sample space  : possible outcomes. Flipping a coin:  = { H, T }

21 21 Inclusion-Exclusion Principle for Probability There are n persons each having an umbrella. All the n umbrellas are put in a box. Suppose each person takes one umbrella randomly from the box. What is the probability that no one gets his/her own umbrella? Let A i be the event that the i-th person gets his/her own umbrella. Then we want the value. For every with, we have By the inclusion-exclusion principle,

22 22 Conditional Probabilities Probability of an event E, P(E) = |E| / |S| P(E | F) = conditional probability of E when given F = |E  F| / |F| = P(E  F) / P(F) F - sum of 2 dices is 4 = {(1,3),(2,2),(3,1)} P(F) = 3/36 = 1/12 P(one dice is 2 and sum of 2 dices is 4) = P(E  F) = 1/36 P(one dice is 2 | sum of 2 dices is 4) = P(E | F) = P(E  F) / P(F) = 1/3 Another view: There is only one (2,2) in F = {(1,3),(2,2),(3,1)} P(one dice is 3 and sum of 2 dices is 4) = 2/36 P(one dice is 3 | sum of 2 dices is 4) = 2/3 P(one dice is 4 given sum of 2 dices is 4) = 0 E F

23 23 Conditional Probabilities P(E | F) = |E  F| / |F| = P(E  F) / P(F) P(E  F) = P(E | F) P(F) = P(F | E) P(E) Example: Prob (sum of 2 dices >9 given one of them is 6) Wrong Argument: If one of them is 6, we’ll get >9 as long as the other is 4,5 or 6. So the probability is ½ E = roll of two dices whose sum >9 = {(6,4), (6,5), (6,6), (5,5), (5,6), (4,6)} ; |E | = 6; P(E) = 1/6 F = roll of two dices, one of which is a 6 = {(6,1),(6,2),(6,3),(6,4),(6,5),(6,6),(5,6),(4,6),(3,6),(2,6),(1,6)}; |F | = 11; P(F) = 11/36 E  F = {(6,4), (6,5), (6,6), (5,6), (4,6)} ; | E  F| = 5, P(E  F) = 5/36 P(E | F) = 5/11; P(F | E) = 5/6

24 24 Conditional Probabilities Example: Given a random bit-string of length 4, what is the probability that it contains two consecutive 0’s given that the first bit is 0? S=sample space of all bit-strings of length 4; |S| = 16 E=all bit-strings with two consecutive 0‘s F=all bit-strings with the first bit 0; ={0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111}; P(F) = |F| / |S| = 8/16 E  F={0000, 0001, 0010, 0011, 0100}; P(E  F) = 5/16 So P(E | F)= P(E  F)/P(F) = 5/8 Another approach by rule of sum (the third rule in the definition) prob (2nd bit is 0) + prob (2nd bit is 1 and the last two bits are 0s) = ½ + ½ x ¼ = 5/8

25 25 Independence Events E and F are independent events if P(E | F) = P(E) i.e., P(E  F) = P(E) P(F) Intuitively: E has nothing to do with F, probability of E would not be affected by F. Example: A coin is tossed twice. What is the probability that the first toss is head given that the second toss is head? S ={(H,H)}, (H,T), (T,H), (T,T)} E =First toss is head = {(H,H)}, (H,T)}; P(E) = ½ F =Second toss is head = {(H,H)}, (T,H)}; P(F) = ½ E  F = both tosses are head = {(H,H)}, P(E  F) = ¼ P(E | F) = P(E  F) / P(F) = ¼ / ½ = ½ (conclusion: independent)

26 26 An Application of Conditional Probability [O3] Known facts: - 1 out of 100,000 person got the disease - if a person got the disease, then diagnostic test is 99% correct - if a person did not get the disease, then the test is 98% correct What is the probability that the person got the disease when the result is positive? F = the person got the disease P(F) = 0.00001 E = the test is positive P(E | F) = accuracy of the test = 0.99 P(E | F) = error of the test = 0.02 In general, there are two types of errors: P(E | F) - false negative P(E | F ) - false positive Our goal is to derive P(F | E).

27 27 The Tree Diagram

28 28 Bayes’ Theorem Given, and, we can derive.

29 29 More on Conditional Probabilities (a) Suppose a person has two children. Given that at least one of them is a boy, what is the probability that the other child is also a boy? (b) Suppose a person has two children. Given that at least one of them is a boy that is born in December, what is the probability that the other child is also a boy? (c) Suppose you roll a die twice. Given that at least one of the outcomes is 6, what is the probability that the other outcome is even?


Download ppt "1 COMP2121 Discrete Mathematics Principle of Inclusion and Exclusion Probability Hubert Chan (Chapters 7.4, 7.5, 6) [O1 Abstract Concepts] [O3 Basic Analysis."

Similar presentations


Ads by Google