Bayes' Theorem

How to reverse a conditional probability using the prior, the likelihood, and the total probability of the observed event. Includes the binary form derived via the law of total probability and the general form for an n-way partition.

Step 1 of 157%

Tutorial

Bayes' Theorem

Suppose we know P(BA)P(B \mid A) but want the reverse conditional probability P(AB)P(A \mid B). Bayes' theorem lets us flip the conditioning:

P(AB)=P(BA)P(A)P(B).P(A \mid B) = \dfrac{P(B \mid A) \, P(A)}{P(B)}.

This follows from writing the joint probability P(AB)P(A \cap B) two different ways using the definition of conditional probability:

P(AB)=P(AB)P(B)=P(BA)P(A).P(A \cap B) = P(A \mid B) \, P(B) = P(B \mid A) \, P(A).

Solving the second equality for P(AB)P(A \mid B) gives Bayes' theorem.

The factor P(A)P(A) is called the prior — our belief about AA before observing BB. The result P(AB)P(A \mid B) is the posterior — our updated belief after observing BB.

For instance, if P(A)=0.4,P(A) = 0.4, P(B)=0.5,P(B) = 0.5, and P(BA)=0.25,P(B \mid A) = 0.25, then

P(AB)=0.250.40.5=0.10.5=0.2.P(A \mid B) = \dfrac{0.25 \cdot 0.4}{0.5} = \dfrac{0.1}{0.5} = 0.2.
navigate · Enter open · Esc close · ⌘K/Ctrl K toggle