The previous example where we computed probabilities in order to classify email as spam is a simple example of what's called a Bayesian analysis. The idea is as follows. Before looking at the email, we already know that about 20% of all email is spam. So there's already a prior probability of 20% that the email is spam. The idea now is to look at the evidence inside the email, such as certain key words like money, and to improve on that prior probability using that evidence we find inside the email. So we did this using the Bayesian formula. And the way to think about this is that the Bayes' rule allows us to improve or update the prior probability into what's called a posterior probability that incorporates the information that we found inside the email. Here's another example where we will use Bayes' rule. Suppose that 1% of the population has a certain disease, and there's a test, that tests for the presence of the disease. If an infected person is tested, then there's a 95% chance that the test is positive, but if the person is not infected, then there's still a 2% chance that a test gives an erroneous positive result. That's called a false positive, because it's a positive result when in fact, the person is not infected. Given that a person tests positive, what are now the chances that he has the disease? So, let's look what probabilities we have. First, there's the 1%, that refers to the probability that a certain person has the disease. So we can write this down as the probability that the disease is present as 1%. Then we have the 95% chance that a test is positive if the person is infected. That's a condition of probability, the probability of a positive test given that the disease is present. Finally, there's the 2%. That refers to the probability of a positive outcome given that the disease is not present. What do we want to know? Well, we want to know the probability that a disease is present given that the test is positive. So now, you see we are looking for a conditional probability when what we have is a conditional probability with the roles of positive outcome and disease flipped around. So, that immediately tells you that you want to use Bayes' rule, because Bayes' rule allows you to flip these two things around. When you plug in, this is what you get. So let's see whether we can get an answer from there right away. We know the probability of a positive test given that the disease is present and we know the probability of the disease being present, but we do not know the probability of a positive test. So this is the case where we want to use the expanded version of Bayes' rule. Now, we can simply plug in, everything that's written there we know. For example, the probability of not having a disease is simply 99% by the complement rule. If you plug in, what you get is 32.4%. This is surprisingly low. After all, there is a positive test. The test seems to be quite good, 95% of the time when the disease is present, the test finds it, and only 2% of the time, when the disease is not present, will the test give an erroneous result. So how come then there's only a 32% chance that the disease is there, if we have a positive test? The reason is, that most of the population does not have the disease. Only 1% of the population has the disease, and the test finds most of those. But there's also a 2% chance of finding the disease for a non-infected person. And since there are so many people who are not infected, that number is quite big, and that's why there's only a 32% chance the disease is present among those tested positive.