Bayes theorem is a bookkeeping rule for reversing conditional probabilities. If you know how likely the evidence is under a hypothesis, and how common the hypothesis is beforehand, you can update after seeing the evidence. The algebra is short. The discipline is in naming the events clearly, and in refusing to treat $P(H\mid E)$ as if it were $P(E\mid H)$.

This page is educational. It is not medical, legal, or diagnostic advice. The numbers below are classroom counts, chosen so the arithmetic stays visible. It belongs to the explainer library and to the probability and statistics pillar. A probability here is a number in a model. It is not a promise about a particular person.

The formula, then the same formula in words

$$P(H\mid E)=\frac{P(E\mid H)\,P(H)}{P(E)}$$

Here $H$ is a hypothesis and $E$ is evidence. The denominator $P(E)$ expands by total probability when $H$ and its complement partition the space:

$$P(E)=P(E\mid H)P(H)+P(E\mid H^c)P(H^c).$$

In words: among all the ways the evidence can appear, what fraction of those appearances come from $H$? The numerator is “evidence and hypothesis.” The denominator is “evidence from anywhere.” Division turns a joint count into a conditional probability.

$P(H)$ is the prior, your probability before seeing $E$. $P(H\mid E)$ is the posterior, after updating. The likelihood $P(E\mid H)$ is not a probability distribution over hypotheses by itself. It measures how well each hypothesis predicts the data.

Think in counts, not in slogans

Example Imagine $10{,}000$ people in a large lecture hall. About $1\%$ have a condition $H$, so $100$ people have $H$ and $9{,}900$ do not. A test is $99\%$ sensitive, meaning $P(E\mid H)=0.99$, and $95\%$ specific, so the false positive rate is $P(E\mid H^c)=0.05$.

About $99$ of the $100$ people with $H$ test positive. Among the $9{,}900$ without $H$, about $495$ false positives appear. So among roughly $594$ positive tests, only about $99$ truly have $H$. That is a bit under $17\%$, not $99\%$. The test is informative. The rare base rate still dominates the headline sensitivity.

Write the same arithmetic through the formula if you prefer symbols:

$$P(H\mid E)=\frac{(0.99)(0.01)}{(0.99)(0.01)+(0.05)(0.99)}=\frac{0.0099}{0.0594}\approx 0.167.$$

The counts and the formula agree. The counts make the $495$ false positives hard to ignore. If you only hear “$99\%$ sensitive,” you never meet those $495$ people.

A card box that is not a medical test

Example A classroom keeps two boxes. Box A has $8$ gold cards and $2$ gray cards. Box B has $1$ gold card and $9$ gray cards. You pick a box at random, so $P(A)=P(B)=\tfrac12$, then draw one card. The card is gold. What is $P(A\mid \text{gold})$?

There are $10$ cards in each box, and the boxes are equally likely, so imagine $20$ equally likely cards across one combined picture. Gold cards: $8$ from A and $1$ from B. Exactly $8$ of those $9$ gold cards came from A. So

$$P(A\mid \text{gold})=\frac{8}{9}.$$

The formula says the same thing: $P(\text{gold}\mid A)=0.8$, $P(\text{gold}\mid B)=0.1$, and

$$P(A\mid \text{gold})=\frac{(0.8)(0.5)}{(0.8)(0.5)+(0.1)(0.5)}=\frac{0.4}{0.45}=\frac{8}{9}.$$

The gold card is evidence for A, because A produces gold cards more often. It is not certainty. One of the nine gold cards still came from B. Bayes theorem is the clean way to keep that leftover possibility in the ledger.

Pitfall. $P(H\mid E)$ is not $P(E\mid H)$. Headlines mix them constantly. Say both in words before you multiply. Also, a prior of $1\%$ is doing real work. If the condition is rarer, the same test produces an even smaller posterior. If you skip the base rate, you are not using Bayes theorem. You are quoting a likelihood and hoping nobody notices.

The same test with a common hypothesis

Example Keep the test from the lecture hall. Sensitivity stays $0.99$. The false positive rate stays $0.05$. Change only the base rate. Suppose half the people have $H$, so the prior is $\tfrac12$ instead of $0.01$.

$$P(H\mid E)=\frac{(0.99)(0.5)}{(0.99)(0.5)+(0.05)(0.5)}=\frac{0.495}{0.520}\approx 0.952.$$

In counts, imagine $10{,}000$ people again. About $5{,}000$ have $H$, and about $4{,}950$ of them test positive. About $5{,}000$ do not have $H$, and about $250$ of those are false positives. Among $5{,}200$ positive tests, about $4{,}950$ truly have $H$. That is near $95\%$, close to the sensitivity. The test did not become more accurate. The hypothesis became common, so the false positives are a small crowd next to the true positives.

Put the two halls side by side. Rare hypothesis, posterior near $17\%$. Common hypothesis, posterior near $95\%$. Anyone who reports "$99\%$ sensitive" as if it were $P(H\mid E)$ is answering $P(E\mid H)$ and discarding the prior. The formula will not do that discarding for you. You have to put $P(H)$ in the numerator and in the total probability for $P(E)$.

A second card, and a posterior that becomes the next prior

The two box story is not finished after one gold card. Suppose you replace the card, so the box is unchanged, and you draw a second card from the same box. It is gold again. The draws are independent given the box. They are not independent if you forget which box you are talking about.

Example Start from the original priors $P(A)=P(B)=\tfrac12$. Two golds with replacement have likelihood $0.8^2=0.64$ under A and $0.1^2=0.01$ under B. Then

$$P(A\mid \text{two golds})=\frac{(0.64)(0.5)}{(0.64)(0.5)+(0.01)(0.5)}=\frac{0.32}{0.325}=\frac{64}{65}.$$

You can also update in stages. After the first gold, the posterior was $\tfrac89$ for A and $\tfrac19$ for B. Use those numbers as the prior for the second gold:

$$P(A\mid \text{second gold})=\frac{(0.8)(8/9)}{(0.8)(8/9)+(0.1)(1/9)}=\frac{6.4}{6.5}=\frac{64}{65}.$$

The two routes match. That is the practical meaning of a posterior. It is the prior you carry into the next piece of evidence. You do not restart at $\tfrac12$ after you have already used the first card, unless the problem really is a fresh box.

Without replacement the second gold tells a sharper story. Box B had only one gold card. After a gold draw from B, no gold remains. So $P(\text{second gold}\mid B,\text{first gold})=0$. Two golds without replacement are impossible under B, and the posterior for A is $1$. Dependence given the box matters. Multiplying $0.1\cdot 0.1$ would be the replacement model, and it would be the wrong likelihood for sampling without replacement. Bayes theorem will accept whichever likelihood you hand it. It will not notice that you described the wrong experiment.

Three boxes, so the partition is not a complement

Example Add box C, with $5$ gold cards and $5$ gray cards. You pick one of the three boxes at random, so each prior is $\tfrac13$, then draw one card. The card is gold. A complement of "box A" is no longer a single hypothesis. The denominator has to add three paths.

Imagine one copy of each box, $30$ cards, equally likely because the boxes were equally likely and each box has $10$ cards. Gold cards: $8$ from A, $1$ from B, and $5$ from C, so $14$ gold cards in the picture. Then

$$P(A\mid \text{gold})=\frac{8}{14}=\frac{4}{7},\qquad P(B\mid \text{gold})=\frac{1}{14},\qquad P(C\mid \text{gold})=\frac{5}{14}.$$

Those three fractions sum to $1$. The formula agrees. The likelihoods are $0.8$, $0.1$, and $0.5$, and

$$P(A\mid \text{gold})=\frac{(0.8)(1/3)}{(0.8+0.1+0.5)(1/3)}=\frac{0.8}{1.4}=\frac{4}{7}.$$

If you forget box C and reuse the two box answer $\tfrac89$, you are solving a different problem. The gold card is less decisive for A once C can also produce gold cards often. Total probability is a sum over the partition you actually have, not over the complement you wish you had.

A decision framework

  1. Name the hypothesis and the evidence in words before you write symbols. "Box A" and "the card is gold" are names. "$H$" and "$E$" are abbreviations you earn after the names are clear.
  2. List the partition. That may be a hypothesis and its complement, or several exclusive hypotheses, as in the three boxes.
  3. Write a prior for every piece of the partition. If a prior is missing, stop. You cannot update yet.
  4. Write $P(E\mid \text{each hypothesis})$. That list is the likelihood. It is not the posterior, and the numbers need not sum to $1$.
  5. Compute $P(E)$ by adding likelihood times prior over the whole partition.
  6. Divide. The numerator is one path to the evidence. The denominator is every path that produces the evidence.
  7. If a new piece of evidence arrives, decide whether it is independent of the previous evidence given the hypothesis. If it is, the posterior becomes the next prior. If it is not, write the joint likelihood for the actual experiment, as in the draw without replacement.
  8. Translate the fraction back into a count. A rare base rate is easy to skip in symbols and hard to skip when $495$ false positives are standing next to $99$ true ones.
Pitfall. Multiplying likelihoods pretends the pieces of evidence are independent given the hypothesis. Classroom draws with replacement can earn that assumption. Repeated reports that share a cause often do not. The formula will still return a sharp fraction. Sharpness is not evidence that the independence assumption was true. Also, a posterior is not an expected value. An expected value is a probability weighted average of a random variable. Do not average the hypotheses when the question asked which hypothesis the evidence supports.

Independence is a modeling claim

If $E$ is independent of $H$, then $P(E\mid H)=P(E)$, and the posterior equals the prior. Evidence that does not change with the hypothesis cannot update the hypothesis. Independence is not a vibe. It is an assumption you can write as an equation and then defend or drop.

When several pieces of evidence arrive, a common first model is to multiply likelihoods as if the pieces are independent given $H$. That may be reasonable for well separated classroom trials. It is often false for real reports that share a cause. The formula does not forgive a bad independence assumption. It will happily return a sharp posterior that your model did not earn.

How to know you understood

  1. In the rare hall of $10{,}000$ people, produce about $99$ true positives and about $495$ false positives, and a posterior a bit under $17\%$.
  2. Repeat the same test with prior $\tfrac12$ and see the posterior move to about $95\%$. Say which input changed.
  3. For two boxes and one gold card, get $\tfrac89$, and say that the leftover gold card came from box B.
  4. For a second gold with replacement, get $\tfrac{64}{65}$ two ways: from the original prior, and from the first posterior used as the next prior.
  5. For three boxes, get $\tfrac{4}{7}$ for box A, and explain why $\tfrac89$ would be the wrong problem.
  6. Name a case where the evidence does not move the prior. That is independence of the evidence and the hypothesis, so $P(E\mid H)=P(E)$.

Try it with the matching tools

The Bayes theorem calculator takes a prior $P(H)$, a likelihood $P(E\mid H)$, and $P(E\mid \text{not }H)$, then reports the posterior $P(H\mid E)$ with $P(E)$ written out. A second mode uses a population and a head count, so you can see expected true positives and false positives before the fraction. Use it after you can name each input in words. The page multiplies whatever you type. It will not repair a swapped conditional.

Try it. On the Bayes theorem calculator, leave the defaults: prior $0.01$, likelihood $0.99$, and $P(E\mid \text{not }H)=0.05$. The posterior should land on $1/6$, about $16.7$ percent, which is the rare hall on this page (about $99$ true positives and about $495$ false positives in $10{,}000$ people). Then set the prior to $0.5$ and watch the posterior move to about $0.952$. The likelihood did not change. The base rate did. You can also switch to count mode with population $10000$ and $100$ people who have $H$.

If the evidence is a count of successes, the binomial probability calculator answers “$n$ independent trials, success probability $p$, chance of exactly $k$ successes.” That number can be a likelihood $P(E\mid H)$ once you choose a prior. On that page, set $n=10$, $p=0.8$, and read $P(X=8)$. Compare with $p=0.1$. Those two likelihoods are numbers you can drop into the Bayes calculator after you choose a prior on the box. The normal CDF and z score calculator is a continuous cousin: how much mass sits below a cutoff under a normal curve.

For choosing $k$ items from $n$, or for lining objects up, the combinatorics calculator is the counting bench. Bayes theorem still needs you to say which count is the hypothesis and which count is the evidence.

Put the prior, the likelihood, and the false positive rate into the calculator, then come back and say the posterior in a sentence.

Open the Bayes theorem calculator

Where this sits on the site

The surrounding map is the probability and statistics pillar. Related glossary terms: Bayes theorem, conditional probability, random variable, expected value.

Citations and further reading

  • OpenIntro Statistics, open textbook, conditional probability and Bayes. openintro.org
  • Khan Academy, Bayes theorem lessons. khanacademy.org
  • Stanford CS109 probability notes. web.stanford.edu/class/cs109
  • Gigerenzer, G., work on natural frequencies in medical decision teaching. Search scholarly overviews for classroom treatments that stay with counts.

Last reviewed: 21 September 2026.