* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download P(B|A)
Survey
Document related concepts
Transcript
Probability 2.0 Independent Events • Events can be "Independent", meaning each event is not affected by any other events. • Example: Tossing a coin. • Each toss of a coin is a perfect isolated thing. • What it did in the past will not affect the current toss. • The chance is simply 1-in-2, or 50%, just like ANY toss of the coin. • So each toss is an Independent Event. Dependent Events • But events can also be "dependent" ... which means they can be affected by previous events ... • Example: Marbles in a Bag • 2 blue and 3 red marbles are in a bag. • What are the chances of getting a blue marble? • The chance is 2 in 5 • But after taking one out the chances change! Marbles in a Bag…. • But after taking one out the chances change! • So the next time: • if we got a red marble before, then the chance of a blue marble next is 2 in 4 • if we got a blue marble before, then the chance of a blue marble next is 1 in 4 Replacement • Note: if we replace the marbles in the bag each time, then the chances do not change and the events are independent: • With Replacement: the events are Independent (the chances don't change) • Without Replacement: the events are Dependent (the chances change) Exercise • There is a 2/5 chance of pulling out a Blue marble, and a 3/5 chance for Red • What are the chances of drawing 2 blue marbles? Solution • The chances of drawing 2 blue marbles is 1/10 Conditional event • The probability that event B occurs, given that event A has occurred, is called a conditional probability. • The conditional probability of B, given A, is denoted by the symbol P(B|A). • In other words, event A has already happened, now what is the chance of event B? • And in our case: P(B|A) = 1/4 • So the probability of getting 2 blue marbles is: • And we write it as • "Probability of event A and event B equals the probability of event A times the probability of event B given event A" Exercise • A bag contains 3 red marbles and 4 blue marbles. Two marbles are drawn at random without replacement. If the first marble drawn is red, what is the probability the second marble is blue? • A box contains 5 green pencils and 7 yellow pencils. Two pencils are chosen at random from the box without replacement. What is the probability they are both yellow? Finding hidden data • Using Algebra we can also "change the subject" of the formula, like this: • Start with: P(A and B) = P(A) x P(B|A) • Swap sides: P(A) x P(B|A) = P(A and B) • Divide by P(A): P(B|A) = P(A and B) / P(A) "The probability of event B given event A equals the probability of event A and event B divided by the probability of event A Example • 45% of the children in a school have a dog, 30% have a cat, and 18% have a dog and a cat. What percent of those who have a cat also have a dog? Bayes’ Theorem • Bayes' theorem. Let A1, A2, ... , An be a set of mutually exclusive events that together form the sample space S. Let B be any event from the same sample space, such that P(B) > 0. Then, P( Ak | B ) = P( Ak ∩ B ) • P( A1 ∩ B ) + P( A2 ∩ B ) + . . . + P( An ∩ B ) http://stattrek.com/probability/bayestheorem.aspx • Note: Invoking the fact that P( Ak ∩ B ) = P( Ak )P( B | Ak ), Baye's theorem can also be expressed as P( Ak | B ) = P( Ak ) P( B | Ak ) • P( A1 ) P( B | A1 ) + P( A2 ) P( B | A2 ) + . . . + P( An ) P( B | An ) When to Apply Bayes’ Theorem • Part of the challenge in applying Bayes' theorem involves recognizing the types of problems that warrant its use. You should consider Bayes' theorem when the following conditions exist. • The sample space is partitioned into a set of mutually exclusive events { A1, A2, . . . , An }. • Within the sample space, there exists an event B, for which P(B) > 0. • The analytical goal is to compute a conditional probability of the form: P( Ak | B ). • You know at least one of the two sets of probabilities described below. – P( Ak ∩ B ) for each Ak – P( Ak ) and P( B | Ak ) for each Ak Example1 • Marie is getting married tomorrow, at an outdoor ceremony in the desert. In recent years, it has rained only 5 days each year. Unfortunately, the weatherman has predicted rain for tomorrow. When it actually rains, the weatherman correctly forecasts rain 90% of the time. When it doesn't rain, he incorrectly forecasts rain 10% of the time. What is the probability that it will rain on the day of Marie's wedding? Solution • The sample space is defined by two mutuallyexclusive events - it rains or it does not rain. Additionally, a third event occurs when the weatherman predicts rain. Notation for these events appears below. • Event A1. It rains on Marie's wedding. • Event A2. It does not rain on Marie's wedding. • Event B. The weatherman predicts rain. Solution • In terms of probabilities, we know the following: P( A1 ) = 5/365 =0.0136985 [It rains 5 days out of the year.] • P( A2 ) = 360/365 = 0.9863014 [It does not rain 360 days out of the year.] • P( B | A1 ) = 0.9 [When it rains, the weatherman predicts rain 90% of the time.] • P( B | A2 ) = 0.1 [When it does not rain, the weatherman predicts rain 10% of the time.] Solution • We want to know P( A1 | B ), the probability it will rain on the day of Marie's wedding, given a forecast for rain by the weatherman. The answer can be determined from Bayes' theorem, as shown below. • P( A1|B ) = _____P ( A1 ) P ( B | A1 )________ • P( A1 ) P( B | A1 ) + P( A2 ) P( B | A2 ) • P( A1 | B ) = (0.014)(0.9) / [ (0.014)(0.9) + (0.986)(0.1) ] • P( A1 | B ) = 0.111 • The entire output of a factory is produced on three machines. The three machines account for 20%, 30%, and 50% of the output, respectively. The fraction of defective items produced is this: for the first machine, 5%; for the second machine, 3%; for the third machine, 1%. If an item is chosen at random from the total output and is found to be defective, what is the probability that it was produced by the third machine? • A solution is as follows. Let Ai denote the event that a randomly chosen item was made by the ith machine (for i = 1,2,3). Let B denote the event that a randomly chosen item is defective. Then, we are given the following information: • P(A1) = 0.2, P(A2) = 0.3, P(A3) = 0.5.If the item was made by machine A1, then the probability that it is defective is 0.05; that is, P(B|A1) = 0.05. Overall, we have • P(B|A1) = 0.05, P(B|A2) = 0.03, P(B|A3) = 0.01.To answer the original question, we first find P(B). That may be done in the following way: • P(B) = Σi P(B|Ai)P(Ai) = (0.05)(0.2) + (0.03)(0.3) + (0.01)(0.5) = 0.024. • Hence 2.4% of the total output of the factory is defective • We are given that B has occurred, and we want to calculate the conditional probability of A3. By Bayes' theorem, • Given that the item is defective, the probability that it was made by the third machine is only 5/24. Although machine 3 produces half of the total output, it produces a much smaller fraction of the defective items. Hence the knowledge that the item selected was defective enables us to replace the prior probability P(A3) = 1/2 by the smaller posterior probability P(A3|B) = 5/24. • 1% of people have a certain genetic defect. 90% of tests for the gene detect the defect. 9.6% of the tests are false positives. If a person gets a positive test result, what are the probability they actually have the genetic defect? • The first step into solving Bayes theorem problems is to assign letters to events: • A = chance of having the faulty gene. That was given in the question as 1%. That also means the probability of not having the gene (~A) is 99%. • X = A positive test result. • So: • P(A|X) = Probability of having the gene given a positive test result. • P(X|A) = Chance of a positive test result given that the person actually has the gene. That was given in the question as 90%. • p(X|~A) = Chance of a positive test if the person doesn’t have the gene. That was given in the question as 9.6% • Now we have all of the information we need to put into the equation: P(A|X) = (.9 * .01) / (.9 * .01 + .096 * .99) = 0.0865 (8.65%). • In a class, 30% have grey eyes, 50% blue eyes and other 20% have other colours. One day they play a game together. In the first run, 65% of the grey ones, 82%blue eyes and 50% with other colours are selected. Now if a child is selected randomly from the class, and we know that she was not in the first game, what is the prob that the child has blue eyes.