Bayes' Theorem Calculator
This Bayes' Theorem Calculator turns the probability of B given A around into the probability of A given B, and shows the working line by line. It 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
- Set up the problem.
- Write the formula.
- Find the probability that A does not happen.
- Find the probability of each way B can happen, through A and through not A.
- Add them to get the probability of B.
- Divide the way through A by the probability of B.
- 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.
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
- How to find the probability that A doesn't happen, covered in the Complement Rule Calculator.
- How to find the probability of two events both happening, covered in the Multiplication Rule of Probability Calculator.
- How to divide by the probability of B, covered in the Conditional Probability Calculator.
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. For two more free worked examples, check out the Bayes' Theorem Notes.
The worked examples below go through the same pattern from start to finish, so you can compare every step with your own working. For more practice, the notes page goes further with extra worked examples and fuller explanations of the ideas behind each step. Use them together to check your answers and to understand why each step works.
See Example 1 Hide Example 1
Problem
Approach
Step-by-step method
- Set up the problem.
- Write the formula.
- Find the probability that A does not happen.
- Find the probability of each way B can happen, through A and through not A.
- Add them to get the probability of B.
- Divide the way through A by the probability of B.
- 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.
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\).
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.
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\).
Problem
Approach
Step-by-step method
- Set up the problem.
- Write the formula.
- Substitute the probability of A and take it away from 1.
Formula
Formula: Complement Rule Formula
This formula gives the probability that A does not happen. Take P(A) away from 1.
Step 1
Step 1 - Set up the problem.
In this problem: We are finding the probability that A does not happen, when \(P(A) = 0.01\).
Step 2
Step 2 - Write the formula.
In this problem: A either happens or it doesn't, and those two chances add up to 1.
Step 3
Step 3 - Substitute the probability of A and take it away from 1.
In this problem: Replacing \(P(A)\) with \(0.01\) gives \(1 - 0.01 = 0.99\).
Final Answer
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.
Step 4a
Step 4a - Find the probability of A and B.
In this problem: Multiplying gives \(0.01 \times 0.9 = 0.009\).
Problem
Approach
Step-by-step method
- Set up the problem.
- Write the formula.
- Substitute the two probabilities into the formula.
- Multiply the probabilities.
Formula
Formula: Multiplication Rule Formula
This formula gives the probability that A and B both happen. Multiply P(A) by the probability of B once A has happened.
Step 1
Step 1 - Set up the problem.
In this problem: We are finding the probability that A and B both happen, when \(P(A) = 0.01\) and \(P(B \mid A) = 0.9\).
Step 2
Step 2 - Write the formula.
In this problem: For both to happen, A happens first, then B happens given that A did. When the two events are independent, \(P(B \mid A)\) is just \(P(B)\).
Step 3
Step 3 - Substitute the two probabilities into the formula.
In this problem: Replacing the two probabilities gives \(P(A \cap B) = 0.01 \times 0.9\).
Step 4
Step 4 - Multiply the probabilities.
In this problem: Multiplying gives \(0.01 \times 0.9 = 0.009\).
Final Answer
Step 4b
Step 4b - Find the probability of not A and B.
In this problem: Multiplying gives \(0.99 \times 0.05 = 0.0495\).
Problem
Approach
Step-by-step method
- Set up the problem.
- Write the formula.
- Substitute the two probabilities into the formula.
- Multiply the probabilities.
Formula
Formula: Multiplication Rule Formula
This formula gives the probability that A and B both happen. Multiply P(A) by the probability of B once A has happened.
Step 1
Step 1 - Set up the problem.
In this problem: We are finding the probability that A' and B both happen, when \(P(A') = 0.99\) and \(P(B \mid A') = 0.05\).
Step 2
Step 2 - Write the formula.
In this problem: For both to happen, A' happens first, then B happens given that A' did. When the two events are independent, \(P(B \mid A)\) is just \(P(B)\).
Step 3
Step 3 - Substitute the two probabilities into the formula.
In this problem: Replacing the two probabilities gives \(P(A' \cap B) = 0.99 \times 0.05\).
Step 4
Step 4 - Multiply the probabilities.
In this problem: Multiplying gives \(0.99 \times 0.05 = 0.0495\).
Final Answer
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\).
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\).
Problem
Approach
Step-by-step method
- Set up the problem.
- Write the formula.
- Substitute the two probabilities into the formula.
- Divide to get the conditional probability.
Formula
Formula: Conditional Probability Formula
This formula gives the probability of A once B is known to have happened. Divide the probability of both by P(B).
Step 1
Step 1 - Set up the problem.
In this problem: We are finding the probability of A once we know B has happened, when \(P(A \cap B) = 0.009\) and \(P(B) = 0.0585\).
Step 2
Step 2 - Write the formula.
In this problem: Knowing B happened shrinks the possible outcomes to B, so the chance of both is divided by the chance of B.
Step 3
Step 3 - Substitute the two probabilities into the formula.
In this problem: Replacing the two probabilities gives \(P(A \mid B) = \frac{0.009}{0.0585}\).
Step 4
Step 4 - Divide to get the conditional probability.
In this problem: Dividing gives \(0.009 \div 0.0585 = \frac{2}{13} \approx 0.1538\).
Final Answer
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.
Final Answer
See Example 2 Hide Example 2
Problem
Approach
Step-by-step method
- Set up the problem.
- Write the formula.
- Find the probability that A does not happen.
- Find the probability of each way B can happen, through A and through not A.
- Add them to get the probability of B.
- Divide the way through A by the probability of B.
- 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.
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\).
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.
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\).
Problem
Approach
Step-by-step method
- Set up the problem.
- Write the formula.
- Substitute the probability of A and take it away from 1.
Formula
Formula: Complement Rule Formula
This formula gives the probability that A does not happen. Take P(A) away from 1.
Step 1
Step 1 - Set up the problem.
In this problem: We are finding the probability that A does not happen, when \(P(A) = 0.5\).
Step 2
Step 2 - Write the formula.
In this problem: A either happens or it doesn't, and those two chances add up to 1.
Step 3
Step 3 - Substitute the probability of A and take it away from 1.
In this problem: Replacing \(P(A)\) with \(0.5\) gives \(1 - 0.5 = 0.5\).
Final Answer
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.
Step 4a
Step 4a - Find the probability of A and B.
In this problem: Multiplying gives \(0.5 \times 0.8 = 0.4\).
Problem
Approach
Step-by-step method
- Set up the problem.
- Write the formula.
- Substitute the two probabilities into the formula.
- Multiply the probabilities.
Formula
Formula: Multiplication Rule Formula
This formula gives the probability that A and B both happen. Multiply P(A) by the probability of B once A has happened.
Step 1
Step 1 - Set up the problem.
In this problem: We are finding the probability that A and B both happen, when \(P(A) = 0.5\) and \(P(B \mid A) = 0.8\).
Step 2
Step 2 - Write the formula.
In this problem: For both to happen, A happens first, then B happens given that A did. When the two events are independent, \(P(B \mid A)\) is just \(P(B)\).
Step 3
Step 3 - Substitute the two probabilities into the formula.
In this problem: Replacing the two probabilities gives \(P(A \cap B) = 0.5 \times 0.8\).
Step 4
Step 4 - Multiply the probabilities.
In this problem: Multiplying gives \(0.5 \times 0.8 = 0.4\).
Final Answer
Step 4b
Step 4b - Find the probability of not A and B.
In this problem: Multiplying gives \(0.5 \times 0.3 = 0.15\).
Problem
Approach
Step-by-step method
- Set up the problem.
- Write the formula.
- Substitute the two probabilities into the formula.
- Multiply the probabilities.
Formula
Formula: Multiplication Rule Formula
This formula gives the probability that A and B both happen. Multiply P(A) by the probability of B once A has happened.
Step 1
Step 1 - Set up the problem.
In this problem: We are finding the probability that A' and B both happen, when \(P(A') = 0.5\) and \(P(B \mid A') = 0.3\).
Step 2
Step 2 - Write the formula.
In this problem: For both to happen, A' happens first, then B happens given that A' did. When the two events are independent, \(P(B \mid A)\) is just \(P(B)\).
Step 3
Step 3 - Substitute the two probabilities into the formula.
In this problem: Replacing the two probabilities gives \(P(A' \cap B) = 0.5 \times 0.3\).
Step 4
Step 4 - Multiply the probabilities.
In this problem: Multiplying gives \(0.5 \times 0.3 = 0.15\).
Final Answer
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\).
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\).
Problem
Approach
Step-by-step method
- Set up the problem.
- Write the formula.
- Substitute the two probabilities into the formula.
- Divide to get the conditional probability.
Formula
Formula: Conditional Probability Formula
This formula gives the probability of A once B is known to have happened. Divide the probability of both by P(B).
Step 1
Step 1 - Set up the problem.
In this problem: We are finding the probability of A once we know B has happened, when \(P(A \cap B) = 0.4\) and \(P(B) = 0.55\).
Step 2
Step 2 - Write the formula.
In this problem: Knowing B happened shrinks the possible outcomes to B, so the chance of both is divided by the chance of B.
Step 3
Step 3 - Substitute the two probabilities into the formula.
In this problem: Replacing the two probabilities gives \(P(A \mid B) = \frac{0.4}{0.55}\).
Step 4
Step 4 - Divide to get the conditional probability.
In this problem: Dividing gives \(0.4 \div 0.55 = \frac{8}{11} \approx 0.7273\).
Final Answer
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.
Final Answer
Notes and Practice Mode
Want to understand the method more deeply? The Bayes' Theorem Notes go through the same pattern with extra worked examples and fuller explanations of the ideas behind each step, so you can see why every step works and not just what to do. When you are ready to test yourself, Bayes' Theorem Practice gives you a new problem at Easy, Medium or Hard level, checks your answer and shows the full working whenever you get one wrong. Practice Mode is available on the Plus and Pro plans.
Login and upgrade to Plus to unlock the full step solution.
Example Problems
Click one to load it into the box and solve it.