Skip to content
IB Diploma ProgrammeSL & HL

Bayes' theorem

Mathematics: Analysis and Approaches SL & HL Chapter Notes

Last updated November 2026

ShareWhatsAppPost

Bayes' theorem notes as a printable PDF.

Read online free. Download a watermarked copy with a free account.

Read the notes

The full Bayes' theorem notes as text: skim, search, and jump between subtopics.

~13 min read

1. Splitting a probability over a partition

Events A₁, A₂, A₃ form a partition when exactly one of them must happen. Two events A and A' always do. Their probabilities add to 1.

To find the probability of a further event B, add the probability of reaching B through each part of the partition. Each path is a product along the branches of a probability tree diagram. The paths are then added.

This total is the denominator of Bayes' theorem, so find it first. The command term find needs the working that leads to the answer.

P(B) = P(A) P(B|A) + P(A') P(B|A')

P(B) = P(A₁) P(B|A₁) + P(A₂) P(B|A₂) + P(A₃) P(B|A₃)

Worked example 13 marks

Reyn is investigating the fertility of a group of adult female foxes. He has developed a clinical test that aims to identify whether or not a given fox is pregnant, and he wants to evaluate the reliability of this test. Reyn knows that

  • 40% of the foxes in the group are pregnant
  • if a fox is pregnant, the probability that it will test positive is 90%
  • if a fox is not pregnant, the probability it will test positive is 20%.

Find the probability that a randomly selected fox from the group will test positive.

  1. 1

    valid initial approach for finding P(positive): drawing a probability tree diagram, or using conditional probability for both paths (M1) [1]

  2. 2

    P(positive) = 0.4 × 0.9 + 0.6 × 0.2 (A1) [1]

  3. 3

    = 0.48 (= 12/25) A1 [1]

2. Bayes' theorem for two events

Conditional probability gives P(A ∩ B) = P(B) P(A|B) and also P(A ∩ B) = P(A) P(B|A). Equate the two and divide by P(B). This reverses the condition: it turns P(B|A) into P(A|B).

The denominator P(B) is the total from block 1. The numerator is one path of that total.

Write the formula first, then substitute in context.

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

P(A|B) = (P(A) P(B|A))/(P(A) P(B|A) + P(A') P(B|A'))

Worked example 13 marks

Reyn is investigating the fertility of a group of adult female foxes. He has developed a clinical test that aims to identify whether or not a given fox is pregnant, and he wants to evaluate the reliability of this test. Reyn knows that

  • 40% of the foxes in the group are pregnant
  • if a fox is pregnant, the probability that it will test positive is 90%
  • if a fox is not pregnant, the probability it will test positive is 20%.

Find the probability that a randomly selected fox from the group is pregnant, given that it tested positive.

  1. 1

    attempt to use conditional probability formula in context: P(pregnant | positive) = (P(pregnant ∩ positive))/(P(positive)) (M1) [1]

  2. 2

    = 0.36/0.48 (A1) [1]

  3. 3

    = 0.75 (= 3/4) A1 [1]

3. Using a tree diagram to apply Bayes' theorem

Draw the first branches for the events you are told the probability of. Draw the second branches for the observed outcome and its complement.

The condition in the question is the outcome that happened. The numerator is the one path through the wanted event to that outcome. The denominator is the sum of every path that ends in that outcome.

A question gives you the probability of the outcome given the cause. It asks for the cause given the outcome. That is the sign to use Bayes' theorem.

P(cause | outcome) = (path through the cause to the outcome)/(sum of all paths to the outcome)

Worked example 14 marks

Do not use a calculator. Machine A makes 60% of the bolts in a factory and machine B makes the other 40%. Of the bolts from A, 2% are defective. Of the bolts from B, 5% are defective. A bolt is chosen at random and is defective. Find the probability that it was made by B.

  1. 1

    path through B to defective: 0.4 × 0.05 = 0.02 (M1) [1]

  2. 2

    P(defective) = 0.6 × 0.02 + 0.4 × 0.05 = 0.032 (A1) [1]

  3. 3

    P(B | defective) = 0.02/0.032 (M1) [1]

  4. 4

    = 5/8 = 0.625 A1 [1]

4. Bayes' theorem for three events

With a partition B₁, B₂, B₃, the denominator has three terms, one for each part. The numerator is the term for the part you want.

The three parts must cover every case, so check that their probabilities add to 1 before you start. The three posterior probabilities P(B_i|A) also add to 1. Use this to check an answer.

P(B_i|A) = (P(B_i) P(A|B_i))/(P(B₁) P(A|B₁) + P(B₂) P(A|B₂) + P(B₃) P(A|B₃))

Worked example 14 marks

Do not use a calculator. Machines A, B and C make 50%, 30% and 20% of the bolts in a factory. The proportions defective are 1%, 2% and 5% respectively. A bolt is chosen at random and is defective. Find the probability that it was made by C.

  1. 1

    0.5 + 0.3 + 0.2 = 1, so the three machines are a partition. Attempt at the total with one term for each machine (M1) [1]

  2. 2

    P(defective) = 0.5 × 0.01 + 0.3 × 0.02 + 0.2 × 0.05 = 0.021 (A1) [1]

  3. 3

    P(C | defective) = (0.2 × 0.05)/0.021 (M1) [1]

  4. 4

    = 0.010/0.021 = 10/21 A1 [1]

5. Why P(A|B) and P(B|A) differ

P(B|A) and P(A|B) are in general not equal. They have the same numerator but different denominators.

When the cause A is rare, P(A) is small. Even an accurate test can then give a P(A|B) much smaller than P(B|A). The many cases without A add up in the denominator.

So read the condition after the bar with care. Ask which event has already happened.

P(A|B) ≠ P(B|A) unless P(A) = P(B)

Worked example 14 marks

Do not use a calculator. In a population, 1% of people have a condition. A test is positive for 95% of people who have the condition and for 5% of people who do not. A person chosen at random tests positive. Find the probability that the person has the condition. Give your answer as a fraction.

  1. 1

    path with the condition: 0.01 × 0.95 = 0.0095 (M1) [1]

  2. 2

    path without it: 0.99 × 0.05 = 0.0495, so P(positive) = 0.059 (A1) [1]

  3. 3

    P(condition | positive) = 0.0095/0.059 (M1) [1]

  4. 4

    = 95/590 = 19/118, which is about 0.161 A1 [1]

Recap

  • A partition is events that cannot overlap and together cover everything. Their probabilities add to 1.
  • Total probability: P(B) = sum P(A_i) P(B|A_i). Multiply along a path, add between paths.
  • Bayes' theorem: P(A|B) = (P(A) P(B|A))/(P(B)). The denominator is the total of block 1.
  • On a tree: one path over the sum of all paths that end in the observed outcome.
  • For three events the denominator has three terms. Check that the prior probabilities add to 1.
  • P(A|B) ≠ P(B|A). A rare cause makes P(A|B) small.
  • Write the formula first. A bare answer with no method may earn no marks.

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. Events A, B and C are mutually exclusive and together make up the whole sample space. P(A) = 0.2 and P(B) = 0.5. State P(C).1 mark
    Answer
    1. P(C) = 1 - 0.2 - 0.5 = 0.3 A1

    Trap: Adding 0.2 + 0.5 gives 0.7, which is P(A ∪ B). The probabilities of a partition must add to 1.

  2. Do not use a calculator. P(A) = 0.3, P(B|A) = 0.5 and P(B|A') = 0.2. Find P(B).3 marks
    Answer
    1. P(B) = P(A) P(B|A) + P(A') P(B|A') (M1)
    2. = 0.3 × 0.5 + 0.7 × 0.2 (A1)
    3. = 0.15 + 0.14 = 0.29 A1

    Trap: Stopping at 0.15 finds only the path through A. The path through A' must be added.

  3. Do not use a calculator. P(A) = 0.3, P(B|A) = 0.5 and P(B|A') = 0.2. Find P(A|B).3 marks
    Answer
    1. P(A|B) = (P(A) P(B|A))/(P(B)) (M1)
    2. P(B) = 0.3 × 0.5 + 0.7 × 0.2 = 0.29 (A1)
    3. P(A|B) = 0.15/0.29 = 15/29 A1

    Trap: P(B|A) = 0.5 is given. It is the reverse of the wanted P(A|B), and the denominator must be P(B), not P(A).

  4. Do not use a calculator. A bag holds two coins. One is fair. The other is biased, with P(heads) = 3/4. One coin is chosen at random and tossed. It lands heads. Find the probability that the biased coin was chosen.4 marks
    Answer
    1. P(heads) = 1/2 × 1/2 + 1/2 × 3/4 (M1)
    2. = 1/4 + 3/8 = 5/8 (A1)
    3. P(biased | heads) = (1/2 × 3/4)/(5/8) (M1)
    4. = 3/8 × 8/5 = 3/5 A1

    Trap: Answering 3/4 gives P(heads | biased). The wanted probability is the reverse and needs the prior 1/2.

  5. A filter marks 95% of spam emails as spam. It also marks 3% of emails that are not spam as spam. 20% of all emails are spam. An email is marked as spam. Find the probability that it really is spam. Give your answer to three significant figures.4 marks
    Answer
    1. P(spam ∩ marked) = 0.2 × 0.95 = 0.19 (A1)
    2. P(marked) = 0.19 + 0.8 × 0.03 = 0.214 (M1)(A1)
    3. P(spam | marked) = 0.19/0.214 = 95/107 = 0.888 (3 s.f.) A1

    Trap: 0.95 is the probability of being marked given spam. The question asks for spam given marked, and the answer is lower because of the non-spam emails marked.

  6. Do not use a calculator. A student travels to school by walking, cycling or bus with probabilities 0.2, 0.3 and 0.5. The probability of being late is 0.1 when walking, 0.2 when cycling and 0.4 when on the bus. (a) Find the probability that the student is late. (b) Given that the student is late, find the probability that the student came by bus.5 marks
    Answer
    1. (a) P(late) = 0.2 × 0.1 + 0.3 × 0.2 + 0.5 × 0.4 (M1)
    2. = 0.02 + 0.06 + 0.20 = 0.28 A1
    3. (b) P(bus ∩ late) = 0.5 × 0.4 = 0.20 (A1)
    4. P(bus | late) = 0.20/0.28, the answer to (a) as denominator (M1)
    5. = 5/7 A1

    Trap: A denominator with only the bus term gives 1. All three routes belong in the denominator, because a late student could have come by any of them.

  7. Three farms X, Y and Z supply 45%, 35% and 20% of the apples sold by a shop. The proportions of bruised apples are 4%, 6% and 8% respectively. An apple is chosen at random and is bruised. (a) Find the probability that the apple is bruised. (b) Find the probability that it came from farm Z. Give your answer to three significant figures. (c) Determine which farm is the most likely source of the bruised apple.6 marks
    Answer
    1. (a) P(bruised) = 0.45 × 0.04 + 0.35 × 0.06 + 0.2 × 0.08 (M1)
    2. = 0.018 + 0.021 + 0.016 = 0.055 A1
    3. (b) P(Z|bruised) = 0.016/0.055 (M1)
    4. = 16/55 = 0.291 (3 s.f.) A1
    5. (c) P(X|bruised) = 18/55 = 0.327 and P(Y|bruised) = 21/55 = 0.382 (M1)
    6. Y has the largest probability, so Y is the most likely source A1

    Trap: Z has the highest bruised rate, 8%, but it supplies the fewest apples. Comparing the rates and ignoring the priors gives Z instead of Y.

  8. Do not use a calculator. In a population, 2% of people have a condition. A test is positive for 99% of people who have it and for 5% of people who do not. (a) Show that the probability that a person who tests positive has the condition is 99/344. (b) Hence find the probability that a person who tests positive does not have the condition.5 marks
    Answer
    1. (a) P(positive) = 0.02 × 0.99 + 0.98 × 0.05 (M1)
    2. = 0.0198 + 0.049 = 0.0688 A1
    3. P(condition | positive) = 0.0198/0.0688 M1
    4. = 198/688 A1
    5. = 99/344 AG
    6. (b) 1 - 99/344 = 245/344 A1

    Trap: A 99% accurate test is not a 99% chance of having the condition. Rare conditions make most positive results false, so the answer to (a) is below 0.3.

  9. Do not use a calculator. At an airport, 10% of bags contain metal. A scanner sounds an alarm for 80% of bags that contain metal and for 10% of bags that do not. Every bag is scanned twice. Given what a bag contains, the two scans are independent. (a) Find the probability that one scan of a randomly chosen bag sounds the alarm. (b) Show that the probability that both scans sound the alarm is 0.073. (c) Both scans of a bag sound the alarm. Find the probability that the bag contains metal.6 marks
    Answer
    1. (a) P(alarm) = 0.1 × 0.8 + 0.9 × 0.1 (M1)
    2. = 0.08 + 0.09 = 0.17 A1
    3. (b) independence given the contents: P(both | metal) = 0.8² = 0.64 and P(both | no metal) = 0.1² = 0.01 M1
    4. P(both) = 0.1 × 0.64 + 0.9 × 0.01 = 0.064 + 0.009 A1
    5. = 0.073 AG
    6. (c) P(metal | both) = 0.064/0.073 (M1)
    7. = 64/73 A1

    Trap: Squaring the answer to (a) gives 0.17² = 0.0289. The scans are independent only once the contents are known, so square inside each branch and then add.

  10. Do not use a calculator. A condition D affects 10% of a population. A test is positive for 90% of people with D and for a proportion p of people without D. Given that a person who tests positive has D with probability 1/2: (a) Find p. (b) Hence find the probability that a person who tests negative has D.7 marks
    Answer
    1. (a) P(+) = 0.1 × 0.9 + 0.9 × p = 0.09 + 0.9p (A1)
    2. P(D|+) = 0.09/(0.09 + 0.9p) = 1/2 M1A1
    3. 0.09 + 0.9p = 0.18, so p = 0.1 A1
    4. (b) P(+) = 0.18, so P(-) = 0.82 (A1)
    5. P(D ∩ -) = 0.1 × (1 - 0.9) = 0.01 (A1)
    6. P(D|-) = 0.01/0.82 = 1/82 A1

    Trap: Writing 0.9/(0.9 + p) = 1/2 leaves out the priors 0.1 and 0.9. It gives p = 0.9, which is wrong.

Say this, not that

Wording that loses the mark, against the wording the mark scheme credits.

Loses the markGets the mark
P(pregnant | positive) = 0.9, the probability given in the questionP(pregnant | positive) = 0.36/0.48, using the conditional probability formula in context
P(positive) = 0.4 × 0.9 = 0.36P(positive) = 0.4 × 0.9 + 0.6 × 0.2, adding every path to a positive
(P(B|A))/(P(B)), with the prior P(A) left out(P(A) P(B|A))/(P(B)), with the prior in the numerator
A denominator with only two terms for three machinesA denominator with one term for each part of the partition

Frequently asked questions

How do I find the probability of an event that can happen through several routes?
Add the probability of reaching the event through each part of the partition. Each route is a product of the probabilities along its branches of a probability tree diagram, and the paths are then added. For two events, P(B) = P(A) P(B|A) + P(A') P(B|A'). Find this total first, because it is the denominator of Bayes' theorem.
What is Bayes' theorem and when do I use it?
P(A|B) = (P(A) P(B|A))/(P(B)) reverses the condition. Use it when a question gives the probability of an outcome given a cause and asks for the cause given the outcome. The denominator is P(B), the sum of every path that ends in the observed outcome.
How do I use a tree diagram to apply Bayes' theorem?
The numerator is the one path through the wanted event to the observed outcome. The denominator is the sum of every path that ends in that outcome. Draw the first branches for the events you know, then the second branches for the observed outcome and its complement.
Why is P(A|B) not equal to P(B|A)?
They have the same numerator but different denominators, so in general they are not equal. When the cause A is rare, P(A) is small, so P(A|B) can be much smaller than P(B|A), even for an accurate test. The many cases without A add up in the denominator.
How do I apply Bayes' theorem when there are three machines or three farms?
The denominator has three terms, one for each part of the partition, and the numerator is the term for the part you want. Check first that the probabilities of the parts add to 1. The three posterior probabilities should also add to 1, which is a useful check on your answer.
Is the probability of a positive test given a condition the same as the probability of the condition given a positive test?
No. The given probability P(positive | pregnant) is the reverse of the one wanted. For the pregnancy example, P(positive) = 0.4 × 0.9 + 0.6 × 0.2 is the denominator, and P(pregnant | positive) = 0.36/0.48, not 0.9.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters