Professor Turing

Study guides

What is Bayes' theorem?

Last updated: 2026-11-23

Bayes' theorem tells you how to update the probability of something after you see new evidence. You start with how likely it was before the evidence, called the prior. You weigh it by how likely the evidence is if the thing is true and if it is not, called the likelihoods. The result is how likely it is now, called the posterior. The theorem is how you turn a statement like “the test is 90 percent accurate” into an answer to the question you care about, which is how likely you are to have the condition after a positive result.

Start learning No account needed

1. Prior, likelihood and posterior

The formula is P(A | B) = P(B | A) × P(A) / P(B). Read P(A | B) as “the probability of A given B.” Say A is “has the condition” and B is “tested positive.” Then P(A) is the prior, the base rate of the condition. P(B | A) is a likelihood, the chance of a positive result if you have the condition. P(B) is the chance of a positive result overall, from people with the condition and people without it. P(A | B) is the posterior, and it is the one you want.

The formula looks symmetric, but the two directions are different questions with different answers. P(B | A) is how the test behaves on people whose status is known. P(A | B) is what a positive result tells you about a person whose status is not known. The example below shows how far apart they can be, and it is easier to see with counts than with symbols, so we build the counts first and the formula second.

2. A worked example: a screening test on 1,000 people

A condition affects 1 percent of the people in a group. A screening test catches 90 percent of the people who have it, which is its sensitivity, and wrongly flags 10 percent of the people who do not, which is its false positive rate. You test 1,000 people, and you want to know how likely it is that someone who tests positive has the condition.

Start with the prior: 1 percent of 1,000 is 10 people with the condition and 990 without. Of the 10, the test catches 90 percent, which is 9 positives and 1 miss. Of the 990, the test wrongly flags 10 percent, which is 99 positives, and the other 891 test negative.

GroupPeopleTest positiveTest negative
Has the condition1091
Does not99099891
Total1,000108892

Now look only at the people who tested positive. There are 9 + 99 = 108 of them, and only 9 have the condition, so the posterior is 9 / 108 = 0.0833, about 8.3 percent. A positive result raises the chance from 1 percent to 8.3 percent, which is a large relative change, and still leaves about 11 in 12 positives without the condition.

The formula gives the same number. P(A) = 0.01, P(B | A) = 0.90, and P(B), the overall chance of a positive, is 0.90 × 0.01 + 0.10 × 0.99 = 0.108. Then P(A | B) = 0.009 / 0.108 = 0.0833. The counts are the formula with the 1,000 people factored out. Output from the script, run on 2026-11-23: P(condition | positive) = 9 / 108 = 0.0833. It comes from a short script, bayes-theorem-example.mjs, that does the same arithmetic.

3. The prior carries weight

Keep the same test and change who is being tested. In a group where 30 percent have the condition, 1,000 people include 300 with it and 700 without. The test finds 90 percent of the 300, which is 270 positives, and wrongly flags 10 percent of the 700, which is 70 false positives. The posterior is now 270 / 340 = 0.7941, about 79 percent. The test did not change, and a positive result means something quite different, because the starting point did. A result from a screening program that tests all comers and a result from a clinic where people come in with symptoms are not worth the same, even when the same test is used.

4. A second positive result

Suppose the person is tested again and is positive again. The posterior from the first test, 0.0833, is now the prior. Of the 108 first positives, 9 have the condition and 99 do not. The second test, if it errs independently of the first, flags 90 percent of the 9, which is 8.1, and 10 percent of the 99, which is 9.9. The new posterior is 8.1 / 18.0 = 0.45. A second positive moves the chance from 8.3 percent to 45 percent. The independence assumption matters, because a repeat of the same test on the same person often shares its errors, and then the second result adds less.

5. A common misconception: a 90 percent accurate test means a positive is 90 percent likely to be right

The test in the example gets the right answer for 90 percent of the 1,000 people (9 + 891 = 900), and it catches 90 percent of the people who have the condition. It is easy to carry that 90 over to the person holding a positive result. But P(positive | condition) = 0.90 and P(condition | positive) = 0.0833 are different numbers, because they answer different questions and have different groups underneath them. The first divides by the 10 people with the condition. The second divides by the 108 people with a positive result, and most of those are healthy people from the much larger healthy group.

The same swap shows up in statistics. A p-value is the probability of data at least this extreme if the null hypothesis is true, P(data at least this extreme | H0). It is not P(H0 | data), the chance that the null hypothesis is true given the data. Getting from the first to the second needs a prior, which is what Bayes' theorem adds.

6. Test yourself

Close this page and answer these from the numbers alone. If the base rate were 10 percent and the test the same, how many of 1,000 people test positive, and how many of those have the condition? What happens to the posterior if the false positive rate drops to 1 percent? Then reopen the page and compare. The step you hesitated on is the part to study again.

For the general method, see how to test yourself.

What the sources found, and their limits

Penn State STAT 414, Introduction to Probability Theory, lesson 6. Eberly College of Science, Pennsylvania State University, sections 6.1 to 6.3. It supports using Bayes' theorem to find P(A | B) when the reverse conditional probability P(B | A) is the known one, the overall probability P(B) built from the parts of a partition, the names prior and posterior, and a screening-test example with a 1 percent base rate in which a positive result raises the chance of disease to only 16 percent. That lesson also works a second positive test by taking the people with a first positive as the new population, and notes that even doctors confuse the forward and reverse probabilities, which is the misconception on this page. Source: 6 Bayes' Theorem, read on 2026-11-23.

American Statistical Association, statement on p-values, 2016. Principle 2 says a p-value does not measure the probability that the studied hypothesis is true, which is the point of the p-value paragraph in section 5. Source: the ASA's release of the statement, read on 2026-11-23. Limits: Penn State describes a test by its sensitivity and specificity, and this page says false positive rate for the same thing as 1 minus the specificity. The condition, the screening test and all figures on this page are ours, made up to show the arithmetic, and are not a claim about any real test.

How Professor Turing helps

Professor Turing is a tutor for adults learning any subject, in college or on their own. It asks you questions instead of giving the final answer, does not grade a bare guess, and remembers what you got wrong. No account is needed to start.

Bring a topic you are studying, such as how to set up a base-rate problem. Its first reply asks what you already know before it teaches anything. If you answer with a bare guess, such as a term, it asks how you got there instead of saying right or wrong, and when you stay stuck it changes its approach and makes the next step smaller instead of giving the final answer. Later in a session it can offer a short test without help, scored apart from the tutoring, so you can tell what you can do alone from what the tutor carried you through.

It does not read or mark a written answer, and it does not write your explanation for you, so the explanation has to be yours. You must be 18 or older, and conversations are deleted after 7 days.

FAQ

How do I set up a Bayes' theorem word problem? Find three numbers in the wording. The first is the prior, how common the thing is before any evidence, such as the 1 percent base rate. The other two are the likelihoods, the chance of the evidence when the thing is true and the chance of the same evidence when it is not, such as 0.90 and 0.10. Then either picture 1,000 people and count who lands in each cell, or put the numbers into the formula. Both routes give the same posterior.

Is Bayes' theorem the same as Bayesian statistics? No. Bayes' theorem is a rule of probability that holds whatever your view of statistics, and the screening example uses it with plain counts. Bayesian statistics uses the same rule to put a prior on unknown quantities, such as a population mean, and update it with data. That is a modeling choice, and some analysts make a different one.

Start with what you're working on

Tell the tutor which topic you are studying and let it ask you the questions.

Start learning No account needed

See also: all study guides