Skip to content
LoveToCalc

Theorem — what does that mean?

Bayes' theorem

The theorem that reverses a condition: from P(B|A) to P(A|B).

In Swedish: Bayes sats

Bayes' theorem

The relation

P(A|B)=P(B|A)P(A)P(B)

Turns a conditional probability around: from the probability of the evidence given the cause to the probability of the cause given the evidence.

Two overlapping circles for the events A and B. The overlap is both at once. P(A|B) is the overlap's share of circle B, P(B|A) is the same overlap's share of circle A, and P(A) and P(B) are the whole circles.
Solve for

P(A|B)=0.5

P(A|B) equals (0.8 times 0.25) divided by 0.4, equals 0.2 divided by 0.4, equals 0.5

Working3 steps

Practice questions

You are given

  • P(B|A)=0.8
  • P(A)=0.5
  • P(B)=0.8

What the formula says

Bayes’ theorem answers a question you rarely have a direct answer to, using the reverse question that you do have an answer to.

P(A|B) = P(B|A) · P(A) / P(B)

Holds when P(B) > 0.

The four parts have names worth knowing:

The theorem follows directly from conditional probability written both ways round. P(A∩B) can be computed as P(A|B)·P(B) and as P(B|A)·P(A). Set those equal and divide by P(B), and Bayes’ theorem is what is left.

A test example

A test detects the disease in 90% of those who have it and gives a false alarm in 10% of those who do not. The disease is present in 1% of the population. You test positive. How likely is it that you have it?

The answer is not 90%. Count a thousand people:

That is 9 + 99 = 108 positive results, and only 9 of them are ill: 9/108 ≈ 8.3%.

In the formula’s terms: P(B|A) = 0.9, P(A) = 0.01, P(B) = 0.108, and

P(A|B) = 0.9 · 0.01 / 0.108 ≈ 0.083.

The gap between 90% and 8% is not an arithmetic slip but the prior. The disease is so rare that the false alarms from the large healthy group drown out the true alarms from the small ill one. This is a common misreading of medical tests, and it has a name: the base rate fallacy.

The denominator, when it is not given

P(B) is often not written out in the problem. It is then computed from the other numbers — every route to B, added up:

P(B) = P(B|A) · P(A) + P(B|Ā) · P(Ā)

Those are the two rows of the thousand-person count: 0.9 · 0.01 + 0.1 · 0.99 = 0.009 + 0.099 = 0.108. The rule is called the law of total probability, and it is almost always the first step before Bayes.

Common mistakes

Common questions

Why is the answer so much lower than the test’s accuracy? Because the healthy are so many more. Being wrong 10% of the time about 990 people is more cases than being right 90% of the time about 10 people.

What are prior and posterior? Before and after the evidence. The prior is what you believed beforehand, the posterior what you believe afterwards. Bayes’ theorem is the rule for how evidence should move your belief.

Do I need the law of total probability every time? Only when P(B) is not stated. If the problem says “8% of all tests come back positive”, you can put that straight in.

Can I do it without the formula? Yes, and for many people it is quicker: set a total of 1000, fill in the four boxes and divide the true positives by all the positives. It is the same arithmetic in whole numbers instead of decimals.

Looking for another letter? The formula solved for each one
Solved for each letter
Solve forRearrangedWith the numbersComes to
P(A|B)P(B|A)P(A)P(B)0.8·0.250.40.5
P(B|A)P(A|B)P(B)P(A)0.5·0.40.250.8
P(A)P(A|B)P(B)P(B|A)0.5·0.40.80.25
P(B)P(B|A)P(A)P(A|B)0.8·0.250.50.4

Last reviewed October 6, 2026 ·How pages are reviewed

Calculate it in practice

Read more in articles

Statistics and probabilityAll formulas

Put this formula on your site

Copy the code into your page where the formula card should appear. It loads from lovetocalc.com, so it stays current on its own — all we ask is that the credit line comes with it.