Bayes' Theorem

Bayes' Theorem updates the probability of a hypothesis given observed evidence, answering what's true given what you now know.

P(AB)=P(BA)P(A)P(B)P(A \mid B) = \frac{P(B \mid A)P(A)}{P(B)}

Solve a problem with Bayes' Theorem

Type the problem. The solver will use Bayes' Theorem where Bayes' Theorem is the right tool, and tell you when it is not.

Drag one in or paste from the clipboard. JPEG, PNG or WebP. You get the transcription to check before anything is solved.

How to get a better answer
  • Paste the whole problem, including the instruction word — "simplify", "solve for x" and "factor" lead to three different answers.
  • Say what you have already tried. "I got x = 4 and the book says 2" turns a solution into a diagnosis.
  • Set the level in the settings button. A calculus shortcut is not a better answer if you have not met derivatives yet.
  • For a photo, get the whole problem in frame and hold the page flat — you get the transcription to fix before anything is solved.

What each symbol means

What Bayes' Theorem takes
AA
BB
Bayes' Theorem
SymbolMeaning
AAAn event or hypothesis whose probability you want to find after observing evidence; if you confuse AA with its complement, the formula will give you the opposite result.
BBThe observed evidence or outcome that you have data about; if you mix it up with a different observation, your calculation answers the wrong question about what you should believe.

When to use it

Use Bayes' Theorem when you observe evidence and need to update your belief about whether a hypothesis is true.

Level

Usually taught in: Statistics · Appears on: AP Statistics

Worked examples

1. Apply Bayes' Theorem with given probabilities

Problem

If P(A)=25P(A) = \frac{2}{5}, P(BA)=34P(B|A) = \frac{3}{4}, and P(B)=12P(B) = \frac{1}{2}, find P(AB)P(A|B).
  1. P(AB)=P(BA)P(A)P(B)P(A|B) = \frac{P(B|A)P(A)}{P(B)}

    We start with Bayes' Theorem.

  2. P(AB)=342512P(A|B) = \frac{\frac{3}{4} \cdot \frac{2}{5}}{\frac{1}{2}}

    We substitute the given values: P(BA)=34P(B|A) = \frac{3}{4}, P(A)=25P(A) = \frac{2}{5}, and P(B)=12P(B) = \frac{1}{2}.

  3. 3425=310\frac{3}{4} \cdot \frac{2}{5} = \frac{3}{10}

    Multiply the numerator fractions: 34×25=310\frac{3}{4} \times \frac{2}{5} = \frac{3}{10}.

  4. P(AB)=31021=610=35P(A|B) = \frac{3}{10} \cdot \frac{2}{1} = \frac{6}{10} = \frac{3}{5}

    Divide by a fraction by multiplying by its reciprocal: 310÷12=310×2=35\frac{3}{10} \div \frac{1}{2} = \frac{3}{10} \times 2 = \frac{3}{5}.

Answer: P(AB)=35P(A|B) = \frac{3}{5}

This example shows the straightforward application of Bayes' Theorem when all necessary probabilities are given directly. We substitute the values and simplify using fraction arithmetic.

2. Calculate total probability before applying Bayes' Theorem

Problem

If P(A)=14P(A) = \frac{1}{4}, P(BA)=45P(B|A) = \frac{4}{5}, P(BAc)=16P(B|A^c) = \frac{1}{6}, and P(Ac)=34P(A^c) = \frac{3}{4}, find P(AB)P(A|B).
  1. P(B)=P(BA)P(A)+P(BAc)P(Ac)P(B) = P(B|A)P(A) + P(B|A^c)P(A^c)

    The law of total probability says we must sum the probability of the evidence over all possible hypotheses.

  2. P(B)=4514+1634=15+18P(B) = \frac{4}{5} \cdot \frac{1}{4} + \frac{1}{6} \cdot \frac{3}{4} = \frac{1}{5} + \frac{1}{8}

    We substitute and multiply: 45×14=15\frac{4}{5} \times \frac{1}{4} = \frac{1}{5} and 16×34=18\frac{1}{6} \times \frac{3}{4} = \frac{1}{8}.

  3. P(B)=840+540=1340P(B) = \frac{8}{40} + \frac{5}{40} = \frac{13}{40}

    Convert to a common denominator: 15=840\frac{1}{5} = \frac{8}{40} and 18=540\frac{1}{8} = \frac{5}{40}, then add.

  4. P(AB)=P(BA)P(A)P(B)=45141340=151340P(A|B) = \frac{P(B|A)P(A)}{P(B)} = \frac{\frac{4}{5} \cdot \frac{1}{4}}{\frac{13}{40}} = \frac{\frac{1}{5}}{\frac{13}{40}}

    Now apply Bayes' Theorem with the calculated value P(B)=1340P(B) = \frac{13}{40}.

  5. P(AB)=154013=4065=813P(A|B) = \frac{1}{5} \cdot \frac{40}{13} = \frac{40}{65} = \frac{8}{13}

    Divide fractions by multiplying by the reciprocal: 15×4013=813\frac{1}{5} \times \frac{40}{13} = \frac{8}{13}.

Answer: P(AB)=813P(A|B) = \frac{8}{13}

This problem demonstrates that Bayes' Theorem often requires calculating the total probability of the evidence first. This computation, using all possible paths to the observed outcome, is essential in real-world applications where P(B)P(B) is not given directly.

3. Find difficulty level probability from observed outcome in a game

Problem

In an RPG, 40% of players attempt a boss fight on expert difficulty with an 80% success rate, while 60% play on normal difficulty with a 50% success rate. If you see a streamer defeat the boss, what is the probability they were playing on expert difficulty?
  1. P(defeat)=P(defeatE)P(E)+P(defeatN)P(N)P(\text{defeat}) = P(\text{defeat}|E)P(E) + P(\text{defeat}|N)P(N)

    Use the law of total probability to find the overall probability of defeating the boss across both difficulties.

  2. P(defeat)=(0.8)(0.4)+(0.5)(0.6)=0.32+0.30=0.62P(\text{defeat}) = (0.8)(0.4) + (0.5)(0.6) = 0.32 + 0.30 = 0.62

    Substitute: expert players are 40% of the population with 80% win rate; normal players are 60% with 50% win rate.

  3. P(Edefeat)=P(defeatE)P(E)P(defeat)=(0.8)(0.4)0.62=0.320.62P(E|\text{defeat}) = \frac{P(\text{defeat}|E)P(E)}{P(\text{defeat})} = \frac{(0.8)(0.4)}{0.62} = \frac{0.32}{0.62}

    Apply Bayes' Theorem where EE is the hypothesis (expert difficulty) and defeat is the observed evidence.

  4. 0.320.62=3262=16310.516\frac{0.32}{0.62} = \frac{32}{62} = \frac{16}{31} \approx 0.516

    Convert to a fraction by eliminating decimals: 3262=1631\frac{32}{62} = \frac{16}{31}, which is about 52%.

Answer: P(Edefeat)=16310.516P(E|\text{defeat}) = \frac{16}{31} \approx 0.516

This real-world-inspired example shows how Bayes' Theorem lets us infer hidden information (difficulty level) from observed outcomes (the boss defeat). It demonstrates why an observed event can reveal what was true before we saw the evidence.

Common mistakes

Where Bayes' Theorem usually goes wrong
Answer came out wrong
Writing P(AB)=P(AB)P(B)P(A)P(A|B) = \frac{P(A|B)P(B)}{P(A)} (swapping the event labels)
Remember the form: P(hypothesisevidence)=P(evidencehypothesis)P(hypothesis)P(evidence)P(\text{hypothesis}|\text{evidence}) = \frac{P(\text{evidence}|\text{hypothesis})P(\text{hypothesis})}{P(\text{evidence})}; BB (evidence) always appears in the conditional on the right side of the fraction.
Forgetting to calculate P(B)P(B) when it is not given and using P(B)=1P(B) = 1 instead
Always calculate P(B)P(B) using the law of total probability: P(B)=P(BA)P(A)+P(BAc)P(Ac)P(B) = P(B|A)P(A) + P(B|A^c)P(A^c); this step is often the longest part of a Bayes' problem.
Confusing which direction the conditional goes and mixing up P(BA)P(B|A) (given in the problem) with P(AB)P(A|B) (what you are trying to find)
Before plugging in numbers, clearly label what you know and what you need: write down whether you have the forward direction or the reverse, and use the formula to convert between them.
The mistakeWhy it is wrongThe fix
Writing P(AB)=P(AB)P(B)P(A)P(A|B) = \frac{P(A|B)P(B)}{P(A)} (swapping the event labels)This reverses the roles of the hypothesis and evidence, putting the wrong conditional probability in the numerator and calculating the reciprocal of what you need.Remember the form: P(hypothesisevidence)=P(evidencehypothesis)P(hypothesis)P(evidence)P(\text{hypothesis}|\text{evidence}) = \frac{P(\text{evidence}|\text{hypothesis})P(\text{hypothesis})}{P(\text{evidence})}; BB (evidence) always appears in the conditional on the right side of the fraction.
Forgetting to calculate P(B)P(B) when it is not given and using P(B)=1P(B) = 1 insteadThe denominator P(B)P(B) is the total probability of the evidence across all possible hypotheses; ignoring it means you do not properly account for how rare or common the observed evidence actually is.Always calculate P(B)P(B) using the law of total probability: P(B)=P(BA)P(A)+P(BAc)P(Ac)P(B) = P(B|A)P(A) + P(B|A^c)P(A^c); this step is often the longest part of a Bayes' problem.
Confusing which direction the conditional goes and mixing up P(BA)P(B|A) (given in the problem) with P(AB)P(A|B) (what you are trying to find)The direction of the conditional completely changes the meaning; P(BA)P(B|A) is the likelihood of evidence given a hypothesis, while P(AB)P(A|B) is the posterior probability of the hypothesis given evidence, and they are never equal unless AA and BB are independent.Before plugging in numbers, clearly label what you know and what you need: write down whether you have the forward direction or the reverse, and use the formula to convert between them.

Tips and when to use something else

  • Always calculate P(B)P(B) using the law of total probability, even if it seems tedious; forgetting this denominator is the most common Bayes' error.
  • If AA and BB are independent events, then P(AB)=P(A)P(A|B) = P(A) and Bayes' Theorem simplifies to a trivial identity, so make sure the events are actually related before applying the formula.
  • When the problem gives you a table or contingency table, you may be faster counting outcomes directly rather than computing probabilities; reserve Bayes' Theorem for when you have probabilities and need to reverse the direction.
  • Use the Complement Rule (P(Ac)=1P(A)P(A^c) = 1 - P(A)) when you need the probability of the opposite event; this is essential when calculating P(B)P(B) via the law of total probability.

Frequently asked questions

What is the difference between P(AB)P(A|B) and P(BA)P(B|A)?
P(AB)P(A|B) is the probability of AA given BB (what Bayes' Theorem finds), while P(BA)P(B|A) is the probability of BB given AA (the likelihood, which appears in the numerator). They answer opposite questions about causation and are generally not equal.
When should I use Bayes' Theorem instead of just reading a probability from a table?
Use Bayes' Theorem when you know the forward probability (evidence given hypothesis) and need the reverse (hypothesis given evidence). If your problem directly gives you the conditional probability you need, read it off; if you must reverse the direction, that is when Bayes' Theorem applies.
What does the denominator P(B)P(B) actually represent?
P(B)P(B) is the total probability of observing the evidence BB, computed by summing over all possible hypotheses. It acts as a normalizing constant that ensures the posterior probability is between 0 and 1, and it accounts for how common the observed evidence is in the overall population.
Can I apply Bayes' Theorem if I do not know P(B)P(B) directly?
Yes—use the law of total probability to calculate it first by summing P(BX)P(X)P(B|X)P(X) over all possible hypotheses XX. For two hypotheses AA and AcA^c, compute P(B)=P(BA)P(A)+P(BAc)P(Ac)P(B) = P(B|A)P(A) + P(B|A^c)P(A^c); this is usually the bulk of the work.

Need a different method?

The full solver is not scoped to one formula — type any problem and it will pick the method.

Open the math solver

Reviewed 2026-09-18