Scribe logoScribeNotes & practice
Sign inStart free
  1. Notes
  2. ›IB Mathematics: Analysis and Approaches
  3. ›4 Statistics and probability
  4. ›4.13 Bayes' theorem

IB Mathematics: Analysis and Approaches · Topic 4 · Statistics and probability

4.13 Bayes' theorem

Apply Bayes’ theorem to update probabilities after new information, using tree diagrams, and interpret the results in context.

  • 4 min read
  • 5 parts
  • 10 questions
  • Draft
  • HL only
Start a Quick 5 on this topic→Jump to the 10 questions
1/5New evidence lets us revise an initial probability
  1. 1New evidence lets us revise an initial probability
  2. 2The law of total probability adds every route to an outcome
  3. 3Bayes’ theorem reverses the direction of conditioning
  4. 4A tree diagram organises every step of the calculation
  5. 5Posterior probabilities can be much smaller than expected
  6. Check your recall
  7. Practice: 10 questions
1

Part 1 of 5: New evidence lets us revise an initial probability

A medical test for a rare condition gives a positive result. You want the chance that the person really has the condition. That differs from the chance that someone with the condition tests positive, which is what the test’s makers measure.

The probability held before the evidence is the prior probability. The updated probability after the evidence is the posterior probability. Both are ordinary probabilities, and only the information behind them differs. The rule that links them reverses the direction of a conditional probability. It lets evidence point back to its likely cause.

Key terms · tap one for its definition

prior probability

A prior probability is the probability assigned to an event before new evidence is observed, such as P(A)P(A)P(A).

posterior probability

A posterior probability is the conditional probability of an event given the new evidence, such as P(A∣B)P(A\mid B)P(A∣B).

Part 1 done

2

Part 2 of 5: The law of total probability adds every route to an outcome

To update a probability we first need the overall chance of the evidence. Let A′A'A′ be the event that AAA does not occur, so P(A′)=1−P(A)P(A')=1-P(A)P(A′)=1−P(A). The evidence BBB can happen after AAA or after A′A'A′, and in no other way.

The law of total probability adds the two routes: P(B)=P(B∣A) P(A)+P(B∣A′) P(A′)P(B)=P(B\mid A)\,P(A)+P(B\mid A')\,P(A')P(B)=P(B∣A)P(A)+P(B∣A′)P(A′). Each term is the chance of reaching BBB by one route. A tree diagram shows these routes as separate paths.

Worked example

Total probability of a defect

Machine A makes 60% of items and 2% of its items are defective. Machine B makes 40% and 5% of its items are defective. Find the probability that a random item is defective.
  1. 1
    Via machine A: 0.6×0.02=0.0120.6\times0.02=0.0120.6×0.02=0.012.
  2. 2
    Via machine B: 0.4×0.05=0.0200.4\times0.05=0.0200.4×0.05=0.020.
  3. 3
    Add the two routes: 0.012+0.0200.012+0.0200.012+0.020.

Answer: P(defective)=0.032P(\text{defective})=0.032P(defective)=0.032.

The same method extends to more than two causes. List every cause, weight each route by its probability, and add all the routes.

Key term

law of total probability

The law of total probability states that P(B)=P(B∣A) P(A)+P(B∣A′) P(A′)P(B)=P(B\mid A)\,P(A)+P(B\mid A')\,P(A')P(B)=P(B∣A)P(A)+P(B∣A′)P(A′) for any event AAA with complement A′A'A′.

Part 2 done

Quick check

One question on the part you just read

Easy

State Bayes’ theorem for P(A∣B)P(A\mid B)P(A∣B).
Show answer and explanation

Answer: C · Worked explanation

Start from P(A∣B)=P(A∩B)P(B)P(A\mid B)=\frac{P(A\cap B)}{P(B)}P(A∣B)=P(B)P(A∩B)​ and replace the numerator with P(B∣A) P(A)P(B\mid A)\,P(A)P(B∣A)P(A). The expression with P(B)P(B)P(B) in the numerator and P(A)P(A)P(A) in the denominator swaps the roles of the two events, so it does not give P(A∣B)P(A\mid B)P(A∣B). The numerator is the joint probability of AAA and BBB, and the denominator is the probability of the evidence.
3

Part 3 of 5: Bayes’ theorem reverses the direction of conditioning

Now suppose an item is found to be defective. We want the reverse probability, that it came from machine A. Start from P(A∣B)=P(A∩B)P(B)P(A\mid B)=\frac{P(A\cap B)}{P(B)}P(A∣B)=P(B)P(A∩B)​ and replace P(A∩B)P(A\cap B)P(A∩B) by P(B∣A) P(A)P(B\mid A)\,P(A)P(B∣A)P(A).

This gives Bayes’ theorem: P(A∣B)=P(B∣A) P(A)P(B)P(A\mid B)=\frac{P(B\mid A)\,P(A)}{P(B)}P(A∣B)=P(B)P(B∣A)P(A)​. Write the denominator using total probability, so that P(B)=P(B∣A) P(A)+P(B∣A′) P(A′)P(B)=P(B\mid A)\,P(A)+P(B\mid A')\,P(A')P(B)=P(B∣A)P(A)+P(B∣A′)P(A′). The numerator is one route to the evidence, and the denominator is every route. The answer is the fraction of all routes that pass through AAA.

Worked example

Which machine made the defective item

Using the machines above, find the probability that a defective item came from machine A.
  1. 1
    Numerator: P(defective∣A) P(A)=0.02×0.6=0.012P(\text{defective}\mid A)\,P(A)=0.02\times0.6=0.012P(defective∣A)P(A)=0.02×0.6=0.012.
  2. 2
    Denominator: P(defective)=0.032P(\text{defective})=0.032P(defective)=0.032.
  3. 3
    Divide: P(A∣defective)=0.0120.032P(A\mid\text{defective})=\frac{0.012}{0.032}P(A∣defective)=0.0320.012​.

Answer: P(A∣defective)=0.375P(A\mid\text{defective})=0.375P(A∣defective)=0.375.

Notice that the posterior of 0.375 is lower than machine A’s share of production, 0.6. Machine B makes fewer items but is more often faulty, so a defect points towards it.

Key term

Bayes’ theorem

Bayes’ theorem states that P(A∣B)=P(B∣A) P(A)P(B)P(A\mid B)=\frac{P(B\mid A)\,P(A)}{P(B)}P(A∣B)=P(B)P(B∣A)P(A)​ for P(B)>0P(B)>0P(B)>0, linking a conditional probability to its reverse.

Part 3 done

4

Part 4 of 5: A tree diagram organises every step of the calculation

Substituting into the formula works, but a tree diagram keeps the numbers tidy. Use the same layout every time, and label every branch before you multiply.

  • Draw first branches for the causes, with prior probabilities.
  • Draw second branches for the evidence, with conditional probabilities.
  • Multiply along each path to get joint probabilities.
  • Add the paths that end in the observed evidence.
  • Divide the path through the cause of interest by that total.
Figure 1. Multiply along each path, add the two positive paths, then divide the condition-and-positive path by that sum.

Worked example

Probability of a condition after a positive test

A condition affects 1% of a population. A test is positive for 95% of people with the condition and for 5% of people without it. A person tests positive. Find the probability that they have the condition.
  1. 1
    Condition and positive: 0.01×0.95=0.00950.01\times0.95=0.00950.01×0.95=0.0095.
  2. 2
    No condition and positive: 0.99×0.05=0.04950.99\times0.05=0.04950.99×0.05=0.0495.
  3. 3
    Total positive: 0.0095+0.0495=0.0590.0095+0.0495=0.0590.0095+0.0495=0.059.
  4. 4
    P(condition∣positive)=0.00950.059P(\text{condition}\mid\text{positive})=\frac{0.0095}{0.059}P(condition∣positive)=0.0590.0095​.

Answer: The probability is ≈0.161\approx0.161≈0.161.

The tree makes each term visible. You can see that most positive results come from the larger branch, where the condition is absent.

Part 4 done

Quick check

One question on the part you just read

Easy

State what a posterior probability is.
Show answer and explanation

Answer: D · Worked explanation

A posterior probability is a conditional probability found after evidence is observed, such as P(A∣B)P(A\mid B)P(A∣B). The probability before any evidence is the prior probability, which is the quantity the posterior updates, so the two terms must not be swapped.
5

Part 5 of 5: Posterior probabilities can be much smaller than expected

The result 0.161 may seem low for a test that detects 95% of cases. The prior was only 0.01. Healthy people are so numerous that their false positives outnumber the true positives. This happens even though each healthy person is unlikely to test positive.

Three different probabilities from the same test

ProbabilityMeaningValue
P(C)P(C)P(C)prior probability of the condition0.01
P(pos∣C)P(\text{pos}\mid C)P(pos∣C)chance that a case tests positive0.95
P(C∣pos)P(C\mid\text{pos})P(C∣pos)posterior after a positive test≈ 0.161
Probability
P(C)P(C)P(C)
Meaning
prior probability of the condition
Value
0.01
Probability
P(pos∣C)P(\text{pos}\mid C)P(pos∣C)
Meaning
chance that a case tests positive
Value
0.95
Probability
P(C∣pos)P(C\mid\text{pos})P(C∣pos)
Meaning
posterior after a positive test
Value
≈ 0.161

A larger prior gives a larger posterior. Here CCC stands for the condition and pos for a positive test. The posterior also depends on how often healthy people test positive.

Common mistake

Do not treat P(pos∣C)P(\text{pos}\mid C)P(pos∣C) as P(C∣pos)P(C\mid\text{pos})P(C∣pos). They answer different questions and are often very different.

Go deeperUpdating twice

After one positive test, the posterior 0.161 becomes the new prior. A second positive result gives 0.161×0.950.161×0.95+0.839×0.05≈0.785\frac{0.161\times0.95}{0.161\times0.95+0.839\times0.05}\approx0.7850.161×0.95+0.839×0.050.161×0.95​≈0.785.

This assumes the two test results are independent, given the person’s true condition. Repeated evidence can therefore raise a small prior a long way.

Note read

Check your recall[14 marks]

5 written questions. Answer each one in your head or on paper, then open the mark scheme.

  1. 1.State[2 marks]

    State Bayes’ theorem for events AAA and BBB with P(B)>0P(B)>0P(B)>0, including an expansion of P(B)P(B)P(B).

    Show mark schemeHide mark scheme

    Model answer

    P(A∣B)=P(B∣A) P(A)P(B)P(A\mid B)=\frac{P(B\mid A)\,P(A)}{P(B)}P(A∣B)=P(B)P(B∣A)P(A)​, where P(B)=P(B∣A) P(A)+P(B∣A′) P(A′)P(B)=P(B\mid A)\,P(A)+P(B\mid A')\,P(A')P(B)=P(B∣A)P(A)+P(B∣A′)P(A′).

    • 1 mark for writing P(A∣B)=P(B∣A) P(A)P(B)P(A\mid B)=\frac{P(B\mid A)\,P(A)}{P(B)}P(A∣B)=P(B)P(B∣A)P(A)​
    • 1 mark for expanding P(B)P(B)P(B) as P(B∣A) P(A)+P(B∣A′) P(A′)P(B\mid A)\,P(A)+P(B\mid A')\,P(A')P(B∣A)P(A)+P(B∣A′)P(A′)
  2. 2.Calculate[4 marks]

    Calculate P(A∣B)P(A\mid B)P(A∣B) to 3 significant figures, given P(A)=0.3P(A)=0.3P(A)=0.3, P(B∣A)=0.8P(B\mid A)=0.8P(B∣A)=0.8 and P(B∣A′)=0.1P(B\mid A')=0.1P(B∣A′)=0.1.

    Show mark schemeHide mark scheme

    Model answer

    P(B∣A) P(A)=0.24P(B\mid A)\,P(A)=0.24P(B∣A)P(A)=0.24 and P(B∣A′) P(A′)=0.1×0.7=0.07P(B\mid A')\,P(A')=0.1\times0.7=0.07P(B∣A′)P(A′)=0.1×0.7=0.07, so P(B)=0.31P(B)=0.31P(B)=0.31. Then P(A∣B)=0.240.31≈0.774P(A\mid B)=\frac{0.24}{0.31}\approx0.774P(A∣B)=0.310.24​≈0.774.

    • 1 mark for finding P(B∣A) P(A)=0.24P(B\mid A)\,P(A)=0.24P(B∣A)P(A)=0.24
    • 1 mark for finding P(B∣A′) P(A′)=0.07P(B\mid A')\,P(A')=0.07P(B∣A′)P(A′)=0.07 and adding to obtain P(B)=0.31P(B)=0.31P(B)=0.31
    • 1 mark for dividing 0.24 by 0.31
    • 1 mark for obtaining 0.774
  3. 3.Explain[3 marks]

    Explain why, for a rare condition CCC, the probability P(C∣pos)P(C\mid\text{pos})P(C∣pos) can be small even when P(pos∣C)P(\text{pos}\mid C)P(pos∣C) is large.

    Show mark schemeHide mark scheme

    Model answer

    Because CCC is rare, the prior is small. Most people do not have CCC, so even a small false-positive rate gives many positive results among them. These false positives can outnumber the true positives, so the posterior is small.

    • 1 mark for stating that the prior probability of CCC is small
    • 1 mark for explaining that many people without the condition still test positive
    • 1 mark for concluding that false positives can outnumber true positives, so the posterior is small
  4. 4.Distinguish[2 marks]

    Distinguish between a prior probability and a posterior probability.

    Show mark schemeHide mark scheme

    Model answer

    A prior probability is held before new evidence is seen, such as P(A)P(A)P(A). A posterior probability is the conditional probability after the evidence, such as P(A∣B)P(A\mid B)P(A∣B).

    • 1 mark for stating that a prior probability is the probability before the evidence
    • 1 mark for stating that a posterior probability is the conditional probability after the evidence
  5. 5.Outline[3 marks]

    Outline how a tree diagram is used to find a posterior probability.

    Show mark schemeHide mark scheme

    Model answer

    Draw first branches for the causes with prior probabilities, then second branches for the evidence with conditional probabilities. Multiply along each path and add the paths ending in the evidence. Divide the path through the cause of interest by that total.

    • 1 mark for drawing branches for causes then evidence with the correct probabilities
    • 1 mark for multiplying along paths and adding those that end in the evidence
    • 1 mark for dividing the path of interest by the total

Practice this topic

10 quick-fire multiple-choice questions, easy to hard. Tap an answer to see if you're right and the worked explanation. (The written questions with mark schemes are under “Check your recall” above.)

0 right0 of 10 answered

Includes the 2 quick checks in the note above.

3.

Easy·State[1 mark]

State the expression that gives P(B)P(B)P(B) by the law of total probability.
Show answer and explanation

Answer: B · Worked explanation

Each route to BBB is weighted by the probability of taking it, and the weighted routes are added. The sum P(B∣A)+P(B∣A′)P(B\mid A)+P(B\mid A')P(B∣A)+P(B∣A′) has no weights, so it can exceed 1, which no probability can do. Check any candidate by setting P(A)=1P(A)=1P(A)=1. The total should then equal P(B∣A)P(B\mid A)P(B∣A), which only the weighted sum gives.
4.

Medium·Calculate[2 marks]

Calculate P(A∣B)P(A\mid B)P(A∣B), given P(A)=0.2P(A)=0.2P(A)=0.2, P(B∣A)=0.9P(B\mid A)=0.9P(B∣A)=0.9 and P(B)=0.3P(B)=0.3P(B)=0.3.
Show answer and explanation

Answer: D · Worked explanation

By Bayes’ theorem, P(A∣B)=0.9×0.20.3=0.180.3=0.60P(A\mid B)=\frac{0.9\times0.2}{0.3}=\frac{0.18}{0.3}=0.60P(A∣B)=0.30.9×0.2​=0.30.18​=0.60. The value 0.18 is only the numerator, which is the joint probability, and has not been divided by P(B)P(B)P(B). The value 0.27 comes from multiplying 0.9 by 0.3. Always divide by the total probability of the evidence, which here is given, and not by the prior.
5.

Medium·Calculate[2 marks]

Calculate P(B)P(B)P(B), given P(A)=0.7P(A)=0.7P(A)=0.7, P(B∣A)=0.1P(B\mid A)=0.1P(B∣A)=0.1 and P(B∣A′)=0.6P(B\mid A')=0.6P(B∣A′)=0.6.
Show answer and explanation

Answer: B · Worked explanation

Add the two weighted routes: 0.7×0.1+0.3×0.6=0.07+0.18=0.250.7\times0.1+0.3\times0.6=0.07+0.18=0.250.7×0.1+0.3×0.6=0.07+0.18=0.25. The value 0.35 is the plain average of 0.1 and 0.6, which ignores the fact that AAA is more likely than A′A'A′. The value 0.18 is only one of the two routes. Always weight each conditional probability by the probability of its route before adding.
6.

Medium·Calculate[2 marks]

Calculate the probability that a defective item came from factory Y. Factory X makes 70% of a firm’s items and 3% of them are defective. Factory Y makes the other 30% and 8% of them are defective.
Show answer and explanation

Answer: B · Worked explanation

The defective routes are 0.7×0.03=0.0210.7\times0.03=0.0210.7×0.03=0.021 and 0.3×0.08=0.0240.3\times0.08=0.0240.3×0.08=0.024, totalling 0.045. So P(Y∣defective)=0.0240.045≈0.533P(Y\mid\text{defective})=\frac{0.024}{0.045}\approx0.533P(Y∣defective)=0.0450.024​≈0.533. The value 0.467 is the probability that the defective item came from factory X, which is the other branch. Check that the two posteriors for the factories add to 1, since 0.533+0.467=10.533+0.467=10.533+0.467=1.
7.

Medium[2 marks]

A condition has prior probability 0.02. A test detects it with probability 0.9. The overall probability of a positive result is 0.116, and the posterior probability given a positive result is about 0.155. State which interpretation is correct.
Show answer and explanation

Answer: A · Worked explanation

The posterior of about 0.155 is larger than the prior of 0.02, so the evidence raises the probability. It stays low because the condition is rare. Comparing 0.155 with 0.9 mixes up the posterior with the probability that the test detects the condition.
8.

Hard·Calculate[2 marks]

Calculate P(C∣pos)P(C\mid\text{pos})P(C∣pos) to 3 significant figures, given P(C)=0.05P(C)=0.05P(C)=0.05, P(pos∣C)=0.8P(\text{pos}\mid C)=0.8P(pos∣C)=0.8 and P(pos∣C′)=0.1P(\text{pos}\mid C')=0.1P(pos∣C′)=0.1.
Show answer and explanation

Answer: B · Worked explanation

The routes to a positive result are 0.05×0.8=0.040.05\times0.8=0.040.05×0.8=0.04 and 0.95×0.1=0.0950.95\times0.1=0.0950.95×0.1=0.095, giving a total of 0.135. Then 0.040.135≈0.296\frac{0.04}{0.135}\approx0.2960.1350.04​≈0.296. The value 0.421 divides 0.04 by 0.095 only, which leaves out the true-positive route from the denominator. Always include both routes to a positive result in the denominator, not only the false-positive route.
9.

Hard·Calculate[2 marks]

Calculate the probability that a red ball came from bag 1. Bag 1 holds 3 red and 2 blue balls, bag 2 holds 1 red and 4 blue balls, and a bag is chosen at random before one ball is drawn.
Show answer and explanation

Answer: D · Worked explanation

The red routes are 0.5×0.6=0.30.5\times0.6=0.30.5×0.6=0.3 and 0.5×0.2=0.10.5\times0.2=0.10.5×0.2=0.1, so the total is 0.4. Then 0.30.4=0.75\frac{0.3}{0.4}=0.750.40.3​=0.75. The value 0.60 is the chance of a red ball from bag 1, which is P(red∣bag 1)P(\text{red}\mid\text{bag 1})P(red∣bag 1), not the posterior. The two posteriors for the bags add to 1, since 0.75+0.25=10.75+0.25=10.75+0.25=1.
10.

Hard·Calculate[2 marks]

Calculate, to 2 significant figures, the probability that a person who tests positive has the condition. The condition affects 1 in 1000 people. The test is positive for 95% of those with it and for 5% of those without it.
Show answer and explanation

Answer: B · Worked explanation

The routes to a positive result are 0.001×0.95=0.000950.001\times0.95=0.000950.001×0.95=0.00095 and 0.999×0.05=0.049950.999\times0.05=0.049950.999×0.05=0.04995, totalling 0.0509. So the probability is 0.000950.0509≈0.019\frac{0.00095}{0.0509}\approx0.0190.05090.00095​≈0.019. The value 0.95 is P(pos∣C)P(\text{pos}\mid C)P(pos∣C), which reverses the conditional probability. A test that detects 95% of cases does not give a 95% chance of the condition when the condition is rare. The posterior depends strongly on the prior.

Keep going

Next topic4.14 Continuous random variablesPrevious topic4.12 Standardizing normal variables

More in Topic 4 · Statistics and probability

  1. 4.6Combined events and diagramsNotes · 10 questions
  2. 4.7Discrete random variablesNotes · 10 questions
  3. 4.8Binomial distributionNotes · 10 questions
  4. 4.9Normal distributionNotes · 10 questions
  5. 4.10Regression of x on yNotes · 10 questions
  6. 4.11Conditional probability and independenceNotes · 10 questions
  7. 4.12Standardizing normal variablesNotes · 10 questions
  8. 4.13Bayes' theoremNotes · 10 questions· HL only
  9. 4.14Continuous random variablesNotes · 10 questions· HL only

All IB Mathematics: Analysis and Approaches topics →

Draft: written by Scribe and checked automatically, not yet by a subject reviewer.

Practice questions are original, written by Scribe and checked automatically for correctness.

Topic codes follow the official numbering. Not endorsed by IB Diploma Programme or any exam board.

On this page

0/5 read

  1. 1New evidence lets us revise an initial probability
  2. 2The law of total probability adds every route to an outcome
  3. 3Bayes’ theorem reverses the direction of conditioning
  4. 4A tree diagram organises every step of the calculation
  5. 5Posterior probabilities can be much smaller than expected
  6. Check your recall
  7. Practice: 10 questions
All coursesScribeHow it worksPricingPrivacyTerms

Notes and questions are written by Scribe in our own words. Topic codes follow the official course numbering so you can find your place. Not produced or endorsed by the IB, College Board, AQA, OCR, Pearson Edexcel or any exam board.

© 2026 Scribe