Bayes' Theorem Notes

Published on: November 26, 2026

These Bayes' Theorem Notes explain how to turn the probability of B given A around into the probability of A given B, with the working shown line by line. The method finds the probability that A does not happen, then the two ways B can happen, through A and through not A. Adding those gives the probability of B, and dividing the way through A by it gives the answer. A tree diagram then shows both branches, which is the pattern behind questions about tests and false alarms.

Step-by-step method

  1. Set up the problem.
  2. Write the formula.
  3. Find the probability that A does not happen.
  4. Find the probability of each way B can happen, through A and through not A.
  5. Add them to get the probability of B.
  6. Divide the way through A by the probability of B.
  7. Show the probabilities on a tree diagram.

Formula: Bayes' Theorem Formula

This formula turns P(B | A) around into P(A | B). Divide the way B happens through A by all the ways B can happen.

\(P(A \mid B) = \frac{P(B \mid A) \times P(A)}{P(B \mid A) \times P(A) + P(B \mid A') \times P(A')}\)

Useful Tips to Remember

Bayes' theorem is \(P(A \mid B) = \frac{P(B \mid A)P(A)}{P(B)}\). \(P(A \mid B)\) and \(P(B \mid A)\) are not the same, and confusing them is the most common mistake. The bottom, \(P(B)\), often has to be built from both cases, \(P(B \mid A)P(A) + P(B \mid A')P(A')\). The starting probability \(P(A)\) matters a lot, especially for rare events.

Required knowledge

Where Is Bayes' Theorem Used?

Bayes' theorem updates a probability when new evidence arrives, turning \(P(B \mid A)\) into \(P(A \mid B)\). It explains why a positive result on a test for a rare disease can still mean the person is probably healthy, because the disease is uncommon to begin with. Spam filters use it to judge whether an email is junk from the words it contains, and it is used in medical diagnosis, forensic science, search and rescue, and machine learning. Any decision that weighs prior knowledge against new data can use it.

  • Interpreting medical test results for rare conditions
  • Filtering spam emails from the words they contain
  • Updating predictions in machine learning
  • Weighing evidence in forensic science
  • Searching for lost ships and planes in search and rescue

Bayes' Theorem Practice Problems

Example 1 is a rare-event problem with \(P(A) = 0.01\), and Example 2 uses \(P(A) = 0.5\). Comparing them shows how much the starting probability changes the answer, so try both yourself first. Examples 3 and 4 give you two more problems of the same kind to try.

The worked examples below go through the same pattern from start to finish, so you can compare every step with your own working. Try each problem on paper first, then open the example and check your working one step at a time, so you can see exactly which step went wrong if your answer does not match. Use them to check your answers and to understand why each step works.

See Example 1 Hide Example 1

Problem

\(P(A) = 0.01,\; P(B \mid A) = 0.9,\; P(B \mid A') = 0.05\)

Approach

Step-by-step method

  1. Set up the problem.
  2. Write the formula.
  3. Find the probability that A does not happen.
  4. Find the probability of each way B can happen, through A and through not A.
  5. Add them to get the probability of B.
  6. Divide the way through A by the probability of B.
  7. Show the probabilities on a tree diagram.

Formula

Formula: Bayes' Theorem Formula

This formula turns P(B | A) around into P(A | B). Divide the way B happens through A by all the ways B can happen.

\(P(A \mid B) = \frac{P(B \mid A) \times P(A)}{P(B \mid A) \times P(A) + P(B \mid A') \times P(A')}\)

Step 1

Step 1 - Set up the problem.

In this problem: We are finding the probability of A once B has happened, when \(P(A) = 0.01\), \(P(B \mid A) = 0.9\) and \(P(B \mid A') = 0.05\).

\(P(A) = 0.01,\; P(B \mid A) = 0.9,\; P(B \mid A') = 0.05\)

Step 2

Step 2 - Write the formula.

In this problem: B can happen with A or without it. Bayes' theorem divides the way through A by both ways together.

\(P(A \mid B) = \frac{P(B \mid A) \times P(A)}{P(B \mid A) \times P(A) + P(B \mid A') \times P(A')}\)

Step 3

Step 3 - Find the probability that A does not happen.

In this problem: Taking \(P(A)\) away from 1 gives \(1 - 0.01 = 0.99\).

\(P(A') = 1 - 0.01 = 0.99\)

Step 4

Step 4 - Find the probability of each way B can happen, through A and through not A.

In this problem: B happens either with A or with not A, so each way is worked out with the multiplication rule.

\(P(A) = 0.01,\; P(A') = 0.99\)

Step 4a

Step 4a - Find the probability of A and B.

In this problem: Multiplying gives \(0.01 \times 0.9 = 0.009\).

\(P(A \cap B) = 0.01 \times 0.9 = 0.009\)

Step 4b

Step 4b - Find the probability of not A and B.

In this problem: Multiplying gives \(0.99 \times 0.05 = 0.0495\).

\(P(A' \cap B) = 0.99 \times 0.05 = 0.0495\)

Step 5

Step 5 - Add them to get the probability of B.

In this problem: Adding the two ways gives \(0.009 + 0.0495 = 0.0585\).

\(P(B) = 0.009 + 0.0495 = 0.0585\)

Step 6

Step 6 - Divide the way through A by the probability of B.

In this problem: Dividing the way through A by all of B gives \(0.009 \div 0.0585 = \frac{2}{13} \approx 0.1538\).

\(P(A \mid B) = \frac{0.009}{0.0585} = \frac{2}{13} \approx 0.1538\)

Step 7

Step 7 - Show the probabilities on a tree diagram.

In this problem: The two orange branches are the ways B can happen. Their ends add up to \(0.0585\), and the A branch is \(0.009\) of it.

Tree diagram for A and B

Final Answer

\(P(A \mid B) = \frac{2}{13} \approx 0.1538\)
See Example 2 Hide Example 2

Problem

\(P(A) = 0.5,\; P(B \mid A) = 0.8,\; P(B \mid A') = 0.3\)

Approach

Step-by-step method

  1. Set up the problem.
  2. Write the formula.
  3. Find the probability that A does not happen.
  4. Find the probability of each way B can happen, through A and through not A.
  5. Add them to get the probability of B.
  6. Divide the way through A by the probability of B.
  7. Show the probabilities on a tree diagram.

Formula

Formula: Bayes' Theorem Formula

This formula turns P(B | A) around into P(A | B). Divide the way B happens through A by all the ways B can happen.

\(P(A \mid B) = \frac{P(B \mid A) \times P(A)}{P(B \mid A) \times P(A) + P(B \mid A') \times P(A')}\)

Step 1

Step 1 - Set up the problem.

In this problem: We are finding the probability of A once B has happened, when \(P(A) = 0.5\), \(P(B \mid A) = 0.8\) and \(P(B \mid A') = 0.3\).

\(P(A) = 0.5,\; P(B \mid A) = 0.8,\; P(B \mid A') = 0.3\)

Step 2

Step 2 - Write the formula.

In this problem: B can happen with A or without it. Bayes' theorem divides the way through A by both ways together.

\(P(A \mid B) = \frac{P(B \mid A) \times P(A)}{P(B \mid A) \times P(A) + P(B \mid A') \times P(A')}\)

Step 3

Step 3 - Find the probability that A does not happen.

In this problem: Taking \(P(A)\) away from 1 gives \(1 - 0.5 = 0.5\).

\(P(A') = 1 - 0.5 = 0.5\)

Step 4

Step 4 - Find the probability of each way B can happen, through A and through not A.

In this problem: B happens either with A or with not A, so each way is worked out with the multiplication rule.

\(P(A) = 0.5,\; P(A') = 0.5\)

Step 4a

Step 4a - Find the probability of A and B.

In this problem: Multiplying gives \(0.5 \times 0.8 = 0.4\).

\(P(A \cap B) = 0.5 \times 0.8 = 0.4\)

Step 4b

Step 4b - Find the probability of not A and B.

In this problem: Multiplying gives \(0.5 \times 0.3 = 0.15\).

\(P(A' \cap B) = 0.5 \times 0.3 = 0.15\)

Step 5

Step 5 - Add them to get the probability of B.

In this problem: Adding the two ways gives \(0.4 + 0.15 = 0.55\).

\(P(B) = 0.4 + 0.15 = 0.55\)

Step 6

Step 6 - Divide the way through A by the probability of B.

In this problem: Dividing the way through A by all of B gives \(0.4 \div 0.55 = \frac{8}{11} \approx 0.7273\).

\(P(A \mid B) = \frac{0.4}{0.55} = \frac{8}{11} \approx 0.7273\)

Step 7

Step 7 - Show the probabilities on a tree diagram.

In this problem: The two orange branches are the ways B can happen. Their ends add up to \(0.55\), and the A branch is \(0.4\) of it.

Tree diagram for A and B

Final Answer

\(P(A \mid B) = \frac{8}{11} \approx 0.7273\)
See Example 3 Hide Example 3

Problem

\(P(A) = 0.2,\; P(B \mid A) = 0.7,\; P(B \mid A') = 0.1\)

Approach

Step-by-step method

  1. Set up the problem.
  2. Write the formula.
  3. Find the probability that A does not happen.
  4. Find the probability of each way B can happen, through A and through not A.
  5. Add them to get the probability of B.
  6. Divide the way through A by the probability of B.
  7. Show the probabilities on a tree diagram.

Formula

Formula: Bayes' Theorem Formula

This formula turns P(B | A) around into P(A | B). Divide the way B happens through A by all the ways B can happen.

\(P(A \mid B) = \frac{P(B \mid A) \times P(A)}{P(B \mid A) \times P(A) + P(B \mid A') \times P(A')}\)

Step 1

Step 1 - Set up the problem.

In this problem: We are finding the probability of A once B has happened, when \(P(A) = 0.2\), \(P(B \mid A) = 0.7\) and \(P(B \mid A') = 0.1\).

\(P(A) = 0.2,\; P(B \mid A) = 0.7,\; P(B \mid A') = 0.1\)

Step 2

Step 2 - Write the formula.

In this problem: B can happen with A or without it. Bayes' theorem divides the way through A by both ways together.

\(P(A \mid B) = \frac{P(B \mid A) \times P(A)}{P(B \mid A) \times P(A) + P(B \mid A') \times P(A')}\)

Step 3

Step 3 - Find the probability that A does not happen.

In this problem: Taking \(P(A)\) away from 1 gives \(1 - 0.2 = 0.8\).

\(P(A') = 1 - 0.2 = 0.8\)

Step 4

Step 4 - Find the probability of each way B can happen, through A and through not A.

In this problem: B happens either with A or with not A, so each way is worked out with the multiplication rule.

\(P(A) = 0.2,\; P(A') = 0.8\)

Step 4a

Step 4a - Find the probability of A and B.

In this problem: Multiplying gives \(0.2 \times 0.7 = 0.14\).

\(P(A \cap B) = 0.2 \times 0.7 = 0.14\)

Step 4b

Step 4b - Find the probability of not A and B.

In this problem: Multiplying gives \(0.8 \times 0.1 = 0.08\).

\(P(A' \cap B) = 0.8 \times 0.1 = 0.08\)

Step 5

Step 5 - Add them to get the probability of B.

In this problem: Adding the two ways gives \(0.14 + 0.08 = 0.22\).

\(P(B) = 0.14 + 0.08 = 0.22\)

Step 6

Step 6 - Divide the way through A by the probability of B.

In this problem: Dividing the way through A by all of B gives \(0.14 \div 0.22 = \frac{7}{11} \approx 0.6364\).

\(P(A \mid B) = \frac{0.14}{0.22} = \frac{7}{11} \approx 0.6364\)

Step 7

Step 7 - Show the probabilities on a tree diagram.

In this problem: The two orange branches are the ways B can happen. Their ends add up to \(0.22\), and the A branch is \(0.14\) of it.

Tree diagram for A and B

Final Answer

\(P(A \mid B) = \frac{7}{11} \approx 0.6364\)
See Example 4 Hide Example 4

Problem

\(P(A) = \frac{1}{3},\; P(B \mid A) = \frac{1}{2},\; P(B \mid A') = \frac{1}{4}\)

Approach

Step-by-step method

  1. Set up the problem.
  2. Write the formula.
  3. Find the probability that A does not happen.
  4. Find the probability of each way B can happen, through A and through not A.
  5. Add them to get the probability of B.
  6. Divide the way through A by the probability of B.
  7. Show the probabilities on a tree diagram.

Formula

Formula: Bayes' Theorem Formula

This formula turns P(B | A) around into P(A | B). Divide the way B happens through A by all the ways B can happen.

\(P(A \mid B) = \frac{P(B \mid A) \times P(A)}{P(B \mid A) \times P(A) + P(B \mid A') \times P(A')}\)

Step 1

Step 1 - Set up the problem.

In this problem: We are finding the probability of A once B has happened, when \(P(A) = \frac{1}{3}\), \(P(B \mid A) = \frac{1}{2}\) and \(P(B \mid A') = \frac{1}{4}\).

\(P(A) = \frac{1}{3},\; P(B \mid A) = \frac{1}{2},\; P(B \mid A') = \frac{1}{4}\)

Step 2

Step 2 - Write the formula.

In this problem: B can happen with A or without it. Bayes' theorem divides the way through A by both ways together.

\(P(A \mid B) = \frac{P(B \mid A) \times P(A)}{P(B \mid A) \times P(A) + P(B \mid A') \times P(A')}\)

Step 3

Step 3 - Find the probability that A does not happen.

In this problem: Taking \(P(A)\) away from 1 gives \(1 - \frac{1}{3} = \frac{2}{3}\).

\(P(A') = 1 - \frac{1}{3} = \frac{2}{3}\)

Step 4

Step 4 - Find the probability of each way B can happen, through A and through not A.

In this problem: B happens either with A or with not A, so each way is worked out with the multiplication rule.

\(P(A) = \frac{1}{3},\; P(A') = \frac{2}{3}\)

Step 4a

Step 4a - Find the probability of A and B.

In this problem: Multiplying gives \(\frac{1}{3} \times \frac{1}{2} = \frac{1}{6}\).

\(P(A \cap B) = \frac{1}{3} \times \frac{1}{2} = \frac{1}{6}\)

Step 4b

Step 4b - Find the probability of not A and B.

In this problem: Multiplying gives \(\frac{2}{3} \times \frac{1}{4} = \frac{1}{6}\).

\(P(A' \cap B) = \frac{2}{3} \times \frac{1}{4} = \frac{1}{6}\)

Step 5

Step 5 - Add them to get the probability of B.

In this problem: Adding the two ways gives \(\frac{1}{6} + \frac{1}{6} = \frac{1}{3}\).

\(P(B) = \frac{1}{6} + \frac{1}{6} = \frac{1}{3}\)

Step 6

Step 6 - Divide the way through A by the probability of B.

In this problem: Dividing the way through A by all of B gives \(\frac{1}{6} \div \frac{1}{3} = 0.5\).

\(P(A \mid B) = \frac{\frac{1}{6}}{\frac{1}{3}} = 0.5\)

Step 7

Step 7 - Show the probabilities on a tree diagram.

In this problem: The two orange branches are the ways B can happen. Their ends add up to \(\frac{1}{3}\), and the A branch is \(\frac{1}{6}\) of it.

Tree diagram for A and B

Final Answer

\(P(A \mid B) = 0.5\)

Calculator and Practice Mode