6.042/18.] Mathematics for Computer Science April 21, 2005 Srini devadas and Eric Lehman Lecture notes Conditional Probability Suppose that we pick a random person in the world. Everyone has an equal chance of being selected. Let A be the event that the person is an MIT student, and let B be the event that the person lives in Cambridge. What are the probabilities of these events? Intuitively were picking a random point in the big ellipse shown below and asking how likely that point is to fall into region A or B et of all people in the world B set of mit set of people who students live in Cambridge The vast majority of people in the world neither live in Cambridge nor are MIT students, o events A and B both have low probability. But what is the probability that a person is an MIT student, given that the person lives in Cambridge? This should be much greater- but what it is exactly? What were asking for is called a conditional probability; that is, the probability that one event happens, given that some other event definitely happens. Questions about conditional probabilities come up all the time What is the probability that it will rain this afternoon, given that it is cloudy this morning What is the probability that two rolled dice sum to 10, given that both are odd? What is the probability that I'll get four-of-a-kind in Texas No Limit Hold'Em Poker, given that I'm initially dealt two queens? There is a special notation for conditional probabilities. In general, Pr(A l B)denotes the probability of event A, given that event B happens. So, in our example, Pr(A l B)is the probability that a random person is an MIT student, given that he or she is a Cam bridge resident
6.042/18.062J Mathematics for Computer Science April 21, 2005 Srini Devadas and Eric Lehman Lecture Notes Conditional Probability Suppose that we pick a random person in the world. Everyone has an equal chance of being selected. Let A be the event that the person is an MIT student, and let B be the event that the person lives in Cambridge. What are the probabilities of these events? Intuitively, we’re picking a random point in the big ellipse shown below and asking how likely that point is to fall into region A or B: A B set of all people in the world set of people who live in Cambridge set of MIT students The vast majority of people in the world neither live in Cambridge nor are MIT students, so events A and B both have low probability. But what is the probability that a person is an MIT student, given that the person lives in Cambridge? This should be much greater— but what it is exactly? What we’re asking for is called a conditional probability; that is, the probability that one event happens, given that some other event definitely happens. Questions about conditional probabilities come up all the time: • What is the probability that it will rain this afternoon, given that it is cloudy this morning? • What is the probability that two rolled dice sum to 10, given that both are odd? • What is the probability that I’ll get fourofakind in Texas No Limit Hold ’Em Poker, given that I’m initially dealt two queens? There is a special notation for conditional probabilities. In general, Pr (A | B) denotes the probability of event A, given that event B happens. So, in our example, Pr (A | B) is the probability that a random person is an MIT student, given that he or she is a Cambridge resident
Conditional Probability How do we compute Pr(A B)? Since we are given that the person lives in Cambridge, we can forget about everyone in the world who does not. Thus, all outcomes outside event B are irrelevant. So, intuitively, Pr(a b) should be the fraction of Cambridge residents that are also MIT students; that is, the answer should be the probability that the person is in set An B(darkly shaded) divided by the probability that the person is in set B(lightly shaded). This motivates the definition of conditional probability P(4|B)=P(B) If Pr(B)=0, then the conditional probability Pr(A l B)is undefined Probability is generally counterintuitive, but conditional probability is the worst! Con ditioning can subtly alter probabilities and produce unexpected results in randomized algorithms and computer systems as well as in betting games. Yet, the mathematical definition of conditional probability given above is very simple and should give you no trouble- provided you rely on formal reasoning and not intuition 1 The halting problem The Halting problem is the canonical undecidable problem in computation theory that was first introduced by Alan Turing in his seminal 1936 paper. The problem is to determine tantly, it is the name of the MIT EECS department's famed C-league hockey team. por whether a Turing machine halts on a given blah, blah, blah. Anyway, much more In a best-of-three tournament, the Halting Problem wins the first game with probability 2. In subsequent games, their probability of winning is determined by the outcome of the previous game. If the Halting Problem won the previous game, then they are envigorated y victory and win the current game with probability 3. If they lost the previous game, then they are demoralized by defeat and win the current game with probablity only What is the probability that the Halting Problem wins the tournament, given that they win the first game? 1.1 Solution to the halting problem This is a question about a conditional probability. Let A be the event that the Halting Problem wins the tournament and let b be the event that they win the first game. Our goal is then to determine the conditional probability Pr(A l B) We can tackle conditional probability questions just like ordinary probability prob below, followed by an explanation of its construction and use te tree diagram is showr lems: using a tree diagram and the four-step method. A com
2 Conditional Probability How do we compute Pr (A | B)? Since we are given that the person lives in Cambridge, we can forget about everyone in the world who does not. Thus, all outcomes outside event B are irrelevant. So, intuitively, Pr (A | B) should be the fraction of Cambridge residents that are also MIT students; that is, the answer should be the probability that the person is in set A ∩ B (darkly shaded) divided by the probability that the person is in set B (lightly shaded). This motivates the definition of conditional probability: Pr (A | B) = Pr (A ∩ B) Pr (B) If Pr (B) = 0, then the conditional probability Pr (A | B) is undefined. Probability is generally counterintuitive, but conditional probability is the worst! Conditioning can subtly alter probabilities and produce unexpected results in randomized algorithms and computer systems as well as in betting games. Yet, the mathematical definition of conditional probability given above is very simple and should give you no trouble— provided you rely on formal reasoning and not intuition. 1 The Halting Problem The Halting Problem is the canonical undecidable problem in computation theory that was first introduced by Alan Turing in his seminal 1936 paper. The problem is to determine whether a Turing machine halts on a given blah, blah, blah. Anyway, much more importantly, it is the name of the MIT EECS department’s famed Cleague hockey team. In a bestofthree tournament, the Halting Problem wins the first game with probability 1 2 . In subsequent games, their probability of winning is determined by the outcome of the previous game. If the Halting Problem won the previous game, then they are envigorated by victory and win the current game with probability 2 3 . If they lost the previous game, then they are demoralized by defeat and win the current game with probablity only 1 3 . What is the probability that the Halting Problem wins the tournament, given that they win the first game? 1.1 Solution to the Halting Problem This is a question about a conditional probability. Let A be the event that the Halting Problem wins the tournament, and let B be the event that they win the first game. Our goal is then to determine the conditional probability Pr (A | B). We can tackle conditional probability questions just like ordinary probability problems: using a tree diagram and the fourstep method. A complete tree diagram is shown below, followed by an explanation of its construction and use
Conditional Probability WW WLW l/18 W WLL 1/9 LWW W W LWL 1/18 1 I st game从 event A: event B outcome 2nd game rd game outcome win the win the outcome utcome outcome series? Ist game? probability Step 1: Find the Sample Space Each internal vertex in the tree diagram has two children, one corresponding to a win for the Halting Problem (labeled W) and one corresponding to a loss (labeled L). The complete sample space is S=WW, WLW, WLL, LWW, LWL, LLI Step 2: Define Events of Interest The event that the Halting Problem wins the whole tournament is T=WW, WLW, LWWI And the event that the halting problem wins the first game is F=WW,WLW,WLLI The outcomes in these events are indicated with checkmarks in the tree diagram Step 3: Determine Outcome Probabilities Next, we must assign a probability to each outcome. We begin by labeling edges as spec ified in the problem statement. Specifically, The Halting Problem has a 1/2 chance of winning the first game, so the two edges leaving the root are each assigned probability 1/ 2. Other edges are labeled 1/3 or 2 /3 based on the outcome of the preceding game We then find the probability of each outcome by multiplying all probabilities along the corresponding root-to-leaf path. For exan 7 ple, the probability of outcome WLL
Conditional Probability 3 2/3 L 1/2 W 1/2 W 1/3 L 2/3 L 1/3 W 2/3 L L 1/3 W 2/3 W 1/3 1st game outcome 2nd game outcome 3rd game outcome probability outcome 1/3 1/18 1/9 1/9 1/18 1/3 event B: win the 1st game? event A: win the series? WW WLW WLL LWW LWL LL outcome Step 1: Find the Sample Space Each internal vertex in the tree diagram has two children, one corresponding to a win for the Halting Problem (labeled W) and one corresponding to a loss (labeled L). The complete sample space is: S = {WW, W LW, W LL, LWW, LW L, LL} Step 2: Define Events of Interest The event that the Halting Problem wins the whole tournament is: T = {WW, W LW, LWW} And the event that the Halting Problem wins the first game is: F = {WW, W LW, W LL} The outcomes in these events are indicated with checkmarks in the tree diagram. Step 3: Determine Outcome Probabilities Next, we must assign a probability to each outcome. We begin by labeling edges as specified in the problem statement. Specifically, The Halting Problem has a 1/2 chance of winning the first game, so the two edges leaving the root are each assigned probability 1/2. Other edges are labeled 1/3 or 2/3 based on the outcome of the preceding game. We then find the probability of each outcome by multiplying all probabilities along the corresponding roottoleaf path. For example, the probability of outcome W LL is: 1 1 2 1 = 2 · 3 · 3 9
Conditional Probability Step 4: Compute Event Probabilities We can now compute the probability that The Halting Problem wins the tournament, given that they win the first game Pr(AB Pr(A∩B) Pr(B Pr(ww,WLwD Pr(wW, WLW,WLLn 1/3+1/18 /3+1/18+1/9 Were done! If the halting problem wins the first game then they win the whole touna ment with probability 7/9 1.2 Why Tree Diagrams Work Weve now settled into a routine of solving probability problems using tree diagrams But weve left a big question unaddressed: what is the mathematical justfication behind those funny little pictures? Why do they work? The answer involves conditional probabilities. In fact, the probabilities that weve been recording on the edges of tree diagrams are conditional probabilities. For example, con- sider the uppermost path in the tree diagram for the Halting Problem, which corresponds to the outcome ww. The first edge is labeled 1/2, which is the probability that the halt ing Problem wins the first game. The second edge is labeled 2/3, which is the probability that the Halting Problem wins the second game, given that they won the first--that's a conditional probability! More generally, on each edge of a tree diagram, we record the probability that the experiment proceeds along that path, given that it reaches the parent vertex So weve been using conditional probabilities all along. But why can we multiply edge probabilities to get outcome probabilities? For example, we concluded that Pr(Ww)= Why is this correct? The answer goes back to the definition of conditional probability. Rewriting this in a lightly different form gives the Product rule for probabilities
4 Conditional Probability Step 4: Compute Event Probabilities We can now compute the probability that The Halting Problem wins the tournament, given that they win the first game: Pr (A | B) = Pr (A ∩ B) Pr (B) Pr ({WW, W LW}) = Pr ({WW, W LW, W LL}) 1/3 + 1/18 = 1/3 + 1/18 + 1/9 7 = 9 We’re done! If the Halting Problem wins the first game, then they win the whole tournament with probability 7/9. 1.2 Why Tree Diagrams Work We’ve now settled into a routine of solving probability problems using tree diagrams. But we’ve left a big question unaddressed: what is the mathematical justficiation behind those funny little pictures? Why do they work? The answer involves conditional probabilities. In fact, the probabilities that we’ve been recording on the edges of tree diagrams are conditional probabilities. For example, consider the uppermost path in the tree diagram for the Halting Problem, which corresponds to the outcome WW. The first edge is labeled 1/2, which is the probability that the Halting Problem wins the first game. The second edge is labeled 2/3, which is the probability that the Halting Problem wins the second game, given that they won the first— that’s a conditional probability! More generally, on each edge of a tree diagram, we record the probability that the experiment proceeds along that path, given that it reaches the parent vertex. So we’ve been using conditional probabilities all along. But why can we multiply edge probabilities to get outcome probabilities? For example, we concluded that: 1 2 Pr (WW) = 2 · 3 1 = 3 Why is this correct? The answer goes back to the definition of conditional probability. Rewriting this in a slightly different form gives the Product Rule for probabilities:
Conditional Probability Rule(product Rule for 2 Events). If Pr(A2)#0, then Pr(A1n A2)=Pr(A1). Pr(A2 A1) Multiplying edge probabilities in a tree diagram amounts to evaluating the right side of this equation. For example Pr(win first game n win second game Pr(win first game)- Pr(win second game win first game So the Product Rule is the formal justification for multiplying edge probabilities to get outcome probabilities To justify multiplying edge probabilities along longer paths, we need a more general form the product rule Rule (product Rule for n Events). IfPr(A1n..n An-1)#0, then Pr(A1∩.∩An)=Pr(A1)Pr(A2|A1)Pr(A3|A1∩A2)…Pr(An|A1∩.∩An-1) Let's interpret this big formula in terms of tree diagrams. Suppose we want to compute the probability that an experiment traverses a particular root-to-leaf path of length n. Let Ai be the event that the experiment traverses the i-th edge of the path. Then A1n...n An is the event that the experiment traverse the whole path. The Product Rule says that the probability of this is the probability that the experiment takes the first edge times the probability that it takes the second, given it takes the first edge, times the probability it takes the third, given it takes the first two edges, and so forth. In other words, the probability of an outcome is the product of the edge probabilities along the corresponding root-to-leaf path 2 A Posteriori probabilities Suppose that we turn the hockey question around: what is the probability that the Halting Problem won their first game, given that they won the series? This seems like an absurd question! After all, if the Halting Problem won the series, then the winner of the first game has already been determined Therefore who won the first game is a question of fact, not a question of probability. However, our mathemati- cal theory of probability contains no notion of one event preceding another- there is no notion of time at all. Therefore, from a mathematical perspective, this is a perfectly valid question. And this is also a meaningful question from a practical perspective. Suppose that you're told that the Halting Problem won the series, but not told the results of indi vidual games. Then, from your perspective, it makes perfect sense to wonder how likely it is that The Halting Problem won the first game
� Conditional Probability 5 Rule (Product Rule for 2 Events). If Pr (A2) = 0 � , then: Pr (A1 ∩ A2) = Pr (A1) · Pr (A2 | A1) Multiplying edge probabilities in a tree diagram amounts to evaluating the right side of this equation. For example: Pr (win first game ∩ win second game) = Pr (win first game) · Pr (win second game | win first game) 1 2 = 2 · 3 So the Product Rule is the formal justification for multiplying edge probabilities to get outcome probabilities! To justify multiplying edge probabilities along longer paths, we need a more general form the Product Rule: Rule (Product Rule for n Events). If Pr (A1 ∩ . . . ∩ An−1) = 0, then: Pr (A1 ∩ . . . ∩ An) = Pr (A1) · Pr (A2 | A1) · Pr (A3 | A1 ∩ A2)· · ·Pr (An | A1 ∩ . . . ∩ An−1) Let’s interpret this big formula in terms of tree diagrams. Suppose we want to compute the probability that an experiment traverses a particular roottoleaf path of length n. Let Ai be the event that the experiment traverses the ith edge of the path. Then A1 ∩ . . . ∩ An is the event that the experiment traverse the whole path. The Product Rule says that the probability of this is the probability that the experiment takes the first edge times the probability that it takes the second, given it takes the first edge, times the probability it takes the third, given it takes the first two edges, and so forth. In other words, the probability of an outcome is the product of the edge probabilities along the corresponding roottoleaf path. 2 A Posteriori Probabilities Suppose that we turn the hockey question around: what is the probability that the Halting Problem won their first game, given that they won the series? This seems like an absurd question! After all, if the Halting Problem won the series, then the winner of the first game has already been determined. Therefore, who won the first game is a question of fact, not a question of probability. However, our mathematical theory of probability contains no notion of one event preceding another— there is no notion of time at all. Therefore, from a mathematical perspective, this is a perfectly valid question. And this is also a meaningful question from a practical perspective. Suppose that you’re told that the Halting Problem won the series, but not told the results of individual games. Then, from your perspective, it makes perfect sense to wonder how likely it is that The Halting Problem won the first game