Bayes' theorem is a formula that describes how to update the probabilities of hypotheses when given evidence. It follows simply from the axioms of conditional probability, but can be used to powerfully reason about a wide range of problems involving belief updates.
Given a hypothesis and evidence , Bayes' theorem states that the relationship between the probability of the hypothesis before getting the evidence and the probability of the hypothesis after getting the evidence is
Many modern machine learning techniques rely on Bayes' theorem. For instance, spam filters use Bayesian updating to determine whether an email is real or spam, given the words in the email. Additionally, many specific techniques in statistics, such as calculating -values or interpreting medical results, are best described in terms of how they contribute to updating hypotheses using Bayes' theorem.
Probability problems are notorious for yielding surprising and counterintuitive results. One famous example--or a pair of examples--is the following:
A couple has 2 children and the older child is a boy. If the probabilities of having a boy or a girl are both 50%, what's the probability that the couple has two boys?
We already know that the older child is a boy. The probability of two boys is equivalent to the probability that the younger child is a boy, which is .
A couple has two children, of which at least one is a boy. If the probabilities of having a boy or a girl are both , what is the probability that the couple has two boys?
At first glance, this appears to be asking the same question. We might reason as follows: “We know that one is a boy, so the only question is whether the other one is a boy, and the chances of that being the case are . So again, the answer is .”
This makes perfect sense. It also happens to be incorrect.
Bayes' theorem centers on relating different conditional probabilities. A conditional probability is an expression of how probable one event is given that some other event occurred (a fixed value). For instance, "what is the probability that the sidewalk is wet?" will have a different answer than "what is the probability that the sidewalk is wet given that it rained earlier?"
For a joint probability distribution over events and , , the conditional probability of given is defined as
In the sidewalk example, where is "the sidewalk is wet" and is "it rained earlier," this expression reads as "the probability the sidewalk is wet given that it rained earlier is equal to the probability that the sidewalk is wet and it rains over the probability that it rains."
Note that is the probability of both and occurring, which is the same as the probability of occurring times the probability that occurs given that occurred: Using the same reasoning, is also the probability that occurs times the probability that occurs given that occurs: . The fact that these two expressions are equal leads to Bayes' Theorem. Expressed mathematically, this is:
Notice that our result for dependent events and for Bayes’ theorem are both valid when the events are independent. In these instances, and , so the expressions simplify.
While this is an equation that applies to any probability distribution over events and , it has a particularly nice interpretation in the case where represents a hypothesis and represents some observed evidence . In this case, the formula can be written as
This relates the probability of the hypothesis before getting the evidence , to the probability of the hypothesis after getting the evidence, . For this reason, is called the prior probability, while is called the posterior probability. The factor that relates the two, , is called the likelihood ratio. Using these terms, Bayes' theorem can be rephrased as "the posterior probability equals the prior probability times the likelihood ratio."
If a single card is drawn from a standard deck of playing cards, the probability that the card is a king is 4/52, since there are 4 kings in a standard deck of 52 cards. Rewording this, if is the event "this card is a king," the prior probability
If evidence is provided (for instance, someone looks at the card) that the single card is a face card, then the posterior probability can be calculated using Bayes' theorem:
Since every King is also a face card, . Since there are 3 face cards in each suit (Jack, Queen, King) , the probability of a face card is . Combining these gives a likelihood ratio of .
Using Bayes' theorem gives .
Bayes' theorem clarifies the two-children problem from the first section:
1. A couple has two children, the older of which is a boy. What is the probability that they have two boys?
2. A couple has two children, one of which is a boy. What is the probability that they have two boys?
Define three events, , , and , as follows:
Question 1 is asking for , and Question 2 is asking for . The first is computed using the simpler version of Bayes’ theorem:
To find , we must determine , the prior probability that the couple has at least one boy. This is equal to . Therefore the desired probability is
For a similarly paradoxical problem, see the Monty Hall problem.
Venn diagrams are particularly useful for visualizing Bayes' theorem, since both the diagrams and the theorem are about looking at the intersections of different spaces of events.
A disease is present in 5 out of 100 people, and a test that is 90% accurate (meaning that the test produces the correct result in 90% of cases) is administered to 100 people. If one person in the group tests positive, what is the probability that this one person has the disease?
The intuitive answer is that the one person is 90% likely to have the disease. But we can visualize this to show that it’s not accurate. First, draw the total population and the 5 people who have the disease:
The circle A represents 5 out 100, or 5% of the larger universe of 100 people.
Next, overlay a circle to represent the people who get a positive result on the test. We know that 90% of those with the disease will get a positive result, so need to cover 90% of circle A, but we also know that 10% of the population who does not have the disease will get a positive result, so we need to cover 10% of the non-disease carrying population (the total universe of 100 less circle A).
Circle B is covering a substantial portion of the total population. It actually covers more area than the total portion of the population with the disease. This is because 14 out of the total population of 100 (90% of the 5 people with the disease + 10% of the 95 people without the disease) will receive a positive result. Even though this is a test with 90% accuracy, this visualization shows that any one patient who tests positive (Circle B) for the disease only has a 32.14% (4.5 in 14) chance of actually having the disease.
Main article: Bayesian theory in science and math
Bayes’ theorem can show the likelihood of getting false positives in scientific studies. An in-depth look at this can be found in Bayesian theory in science and math.
Many medical diagnostic tests are said to be % accurate, for instance 99% accurate, referring specifically to the probability that the test result is correct given your condition (or lack thereof). This is not the same as the posterior probability of having the disease given the result of the test. To see this in action, consider the following problem.
The world had been harmed by a widespread Z-virus, which already turned 10% of the world's population into zombies.
The scientists then invented a test kit with the sensitivity of 90% and specificity of 70%: 90% of the infected people will be tested positive while 70% of the non-infected will be tested negative.
If the test kit showed a positive result, what would be the probability that the tested subject was truly zombie?
If the solution is in a form of , where and are coprime positive integers, submit your answer as .
A disease test is advertised as being 99% accurate: if you have the disease, you will test positive 99% of the time, and if you don't have the disease, you will test negative 99% of the time.
If 1% of all people have this disease and you test positive, what is the probability that you actually have the disease?
Balls numbered 1 through 20 are placed in a bag. Three balls are drawn out of the bag without replacement. What is the probability that all the balls have odd numbers on them?
In this situation, the events are not independent. There will be a chance that any particular ball is odd. However, the probability that all the balls are odd is not . We do have that the probability that the first ball is odd is For the second ball, given that the first ball was odd, there are only 9 odd numbered balls that could be drawn from a total of 19 balls, so the probability is . For the third ball, since the first two are both odd, there are 8 odd numbered balls that could be drawn from a total of 18 remaining balls. So the probability is .
So the probability that all 3 balls are odd numbered is Notice that , whereas
A family has two children. Given that one of the children is a boy, what is the probability that both children are boys?
We assume that the probability of a child being a boy or girl is . We solve this using Bayes’ theorem. We let be the event that the family has one child who is a boy. We let be the event that both children are boys. We want to find . We can easily see that . We also note that and . So .
A family has two children. Given that one of the children is a boy, and that he was born on a Tuesday, what is the probability that both children are boys?
Your first instinct to this question might be to answer , since this is obviously the same question as the previous one. Knowing the day of the week a child is born on can’t possibly give you additional information, right?
Let’s assume that the probability of being born on a particular day of the week is and is independent of whether the child is a boy or a girl. We let be the event that the family has one child who is a boy born on Tuesday and be the event that both children are boys, and apply Bayes’ Theorem. We notice right away that is no longer equal to one. Given that there are 7 days of the week, there are 49 possible combinations for the days of the week the two boys were born on, and 13 of these have a boy who was born on a Tuesday, so . remains unchanged at . To calculate , we note that there are possible ways to select the gender and the day of the week the child was born on. Of these, there are ways which do not have a boy born on Tuesday, and which do, so . This gives is that .
Note: This answer is certainly not , and is actually much closer to .
Zeb's coin box contains 8 fair, standard coins (heads and tails) and 1 coin which has heads on both sides. He selects a coin randomly and flips it 4 times, getting all heads. If he flips this coin again, what is the probability it will be heads? (The answer value will be from 0 to 1, not as a percentage.)
There are 10 boxes containing blue and red balls.
The number of blue balls in the box is given by .
The number of red balls in the box is given by .
A box is picked at random, and a ball is chosen randomly from that box. If the ball is blue, and the probability that the box was picked can be expressed as , where and are coprime positive integers, find .
More probability questions
Photo credit: http://www.spi-global.com/