 So let's talk about Bayes' theorem. This is arguably the most important thing you could learn in a course on elementary probability and statistics. I would go so far as to say if you learn nothing else in this course, you'll probably fail the course. But if you do learn Bayes' theorem, you will have learned something extremely important. So this goes back to the idea of conditional probabilities. So let's suppose we have a 2 by 2 contingency table for our two events, A and B, where either A occurs or it doesn't, and B occurs or it doesn't, and we have the frequencies, the times that it has occurred, and we've extended our totals. Now again, remember that in general, we cannot assume any relationship between the probability of A given that B has occurred and the probability that B occurs given that we know that A has occurred. But is there some relationship we can express between the two events? And certainly there does seem to be at least some connection between the two because if we compute the relevant conditional probabilities, we find that the probability of A, given that B has occurred, so we know we're in the B occurs, A plus B total cases, A has occurred A times. And so the frequency with which that occurs, A out of A plus B. Likewise, the probability that B occurs given that we know that A has occurred, we know that A has occurred, so in this A plus C cases, and of those times, we've observed B occurring A times and it gives us our probability A over A plus C. And the fact that our numerators here are actually the same number causes us to at least hope that there is some useful relationship between the two probabilities. So we'll employ a standard tactic in mathematics. We have no idea what to do next, so we'll try anything. One standard thing we might do. If I want to compare two numerical amounts, what I might look at is what is their ratio? So let's take a look at the ratio between those two probabilities. And so I know what the two probabilities are and I can express them as a ratio. And because this numerator A is the same in both cases, then when I simplify, I get the fraction A plus C over A plus B. And the thing that I might want to notice here is that A plus C is the number of times that A has occurred. A plus B is the number of times B has occurred. Now, one of the things that makes things easier in mathematics is if we work with consistency. So over here on the left, we have probabilities. Over here on the right, we have actual numbers of occurrences. And if we take the frequentist viewpoint, we can convert these actual numbers of occurrences into probabilities by dividing by the number of times they could have occurred. So let's take a look at this. This A plus C, that is the number of times that A occurred out of a total of A plus B plus C plus D times. Likewise, this A plus B, that's the number of times that B occurred out of a total possibility of, again, A plus B plus C plus D. So I can divide both by that amount and I can recover two probabilities. Starting with the first, so this A plus C is the number of times that A occurred out of all the times it could have happened. So this is the probability of A, according to our frequentist viewpoint. Likewise, this A plus B is the number of times that B occurred out of all the times that it could have occurred. And so that's just our probability of B. And we have this wonderful relationship between the two conditional probabilities that they are equal to, the ratio, is equal to the ratio between the probabilities of the events themselves. Well, nobody really likes dealing with fractions. So I'll go ahead and cross multiply to eliminate them. So that's probability of A given B times probability of B, probability of A times the probability of B given A. And I have a version of what is known as Bayes' theorem. And this is a very beautiful relationship between the probabilities of two events, given that we know that one of them has occurred. Now Bayes' theorem is particularly useful when we think about the odds of an event occurring or not. So remember that the odds of an event are the ratio of the probability that an event occurs to the probability that it does not. So going back to my event A, I can talk about the odds that A occurs will be the quotient of the probability that A occurs over the probability that A does not occur. Now, it's useful to think about this in a Bayesian framework. So let's consider that these are the odds, but from our Bayesian viewpoint, these are the odds based on a complete lack of any other information. And so we'll call these the prior odds. If I know nothing else, then my level of confidence that A occurs can be expressed as the odds, probability of A over the probability of not A. On the other hand, suppose that I know some other event has occurred. So what if I knew that B has occurred? We can then reconsider what our estimate of the odds is. We can look at what's called the posterior odds, and these are the revised level of confidence that we have that this event A has occurred. And so we can express that this is the probability that A has occurred given that we know that B has occurred over the probability that A has not occurred given that we know that B has occurred. And at this point, we can use Bayes' theorem. So let's consider what we have by Bayes' theorem. By Bayes' theorem, we have this relationship between the probability that A has occurred given that B has occurred and the probability that B has occurred given that A has occurred. Now, if I wanted to, I could consider a couple of different events because I'm interested in the probability that A has occurred and the probability that A has not occurred, it might be worth looking at this set of conditional probabilities. The probability that A did not occur given that B has occurred. The probability that B did occur given that A did not occur. And I have Bayes' theorem. This relationship. So if I divide the one by the other, I get the following quotient. So the probability of A given B over the probability of not A given B, this over that, the probabilities with B drop out, and then the probability of B given A over the probability of B given A did not occur times the probability of A over the probability of A not occurring. Now, this rather daunting expression actually breaks down rather cleanly into three components. So let's take a close look at that. If we take a look at this fraction over here, this is the probability that A occurs divided by the probability that A did not occur, and these are just the prior odds. Meanwhile, if I look at this fraction over here, this is the probability that A occurred given that B occurred divided by the probability that A did not occur given that B has occurred. And those are just the posterior odds. And then we have this expression here. Now, this is not an odds. This does not represent any odds because this is just the probability that B occurs given two different scenarios behind what we think has occurred. So it's not an odds, but because it has multiplied the prior odds to obtain the posterior odds, we refer to this quantity as the odds multiplier. And there's a funny thing about odds. There are many cases where we don't know the odds of an event, but it's actually pretty easy to find the odds multipliers. A good example might be the following. Let's consider the event where D is that a person has diabetes and M is the event that a person tests positive for diabetes. So you go in, you see the doctor, they run a test and the test comes back that you have diabetes. So the question is, how worried should you be? Well, this is a situation where it's possible that we might not know probability of D. In other words, we might not know the probability that a person has diabetes. So that means we won't be able to find the odds that you have diabetes. On the other hand, there's an important conditional probability associated with this problem, which is the probability that you test positive for diabetes, given that you have diabetes. So that corresponds to the sensitivity of the test. And the important thing about this is that we can determine the sensitivity under laboratory conditions. We take a whole bunch of people who we know for certain have diabetes and we administer the tests and we see how many of those people actually test positive. And since we know they have diabetes, the frequency that we get positive results will be our probability that the test returns positive given that we know that a person has diabetes. What about the other component of the accuracy of a test? Well, that's our specificity and that's the probability that a person without diabetes tests negative. So again, this is something we can find under laboratory condition. We'll take a whole bunch of people who we know do not have diabetes, we administer to the test to them and we determine how often they have a negative result. And that frequency that they get a negative result is our specificity and whatever it's left over is this probability that they test positive given that we know they do not in fact have diabetes. This corresponds to our false positives. So how does Swiss work in practice? Well, let's consider a typical medical test for diabetes and for example, for argument's sake, so as the sensitivity of the test is 95% and the specificity of the test is 80%. So what does this give us? So first off, we can write down our relationship between the conditional probabilities and fill in the blanks. So let's see what information we have. So here again, we have our prior odds that a person has diabetes, we have our posterior odds that a person has diabetes and then we have our odds multiplier here. So let's take a close look at that. This is the probability that a person tests positive given that they have diabetes, given that we know for certain that the person has diabetes and that corresponds to our sensitivity 95%, so we'll drop it in there. This is our probability that a person tests positive given that we know they are not diabetic. Now, be careful with this. The specificity is the probability or the frequency that the person tests negative given that they do not have the medical condition. So if the specificity is 80%, what that says is the probability that the person will test positive, even though they don't have diabetes, is gonna be the remainder, that's gonna be 20%. And then, expressing those values in there, we have our odds multiplier 0.95 over 0.2 who works out to be about 4.5. And now we have our expression that relates the prior odds of having diabetes to the posterior odds of having diabetes. And so, in words, this is the odds that a person has diabetes given that they've tested positive is four and a half times the odds that they have diabetes in the first place. And so that means whatever the odds were that the person had diabetes would be increased by a factor of 4.5 if they, in fact, tested positive.