Attic › Mathematics › Bayes' theorem

The theorem compares the probability of the evidence in one scenario to its probability in all scenarios

Bayes' theorem works by comparing the chance that your hypothesis produced the evidence to the total chance of seeing that evidence in any way. Each of the four parts in the formula P(A | B) = [P(B | A) × P(A)] / P(B) has a name and a specific job.

1. Prior probability, P(A): This is the initial probability of your hypothesis (A) before you look at the new evidence (B). It represents what you already know.

2. Likelihood, P(B | A): This is the probability of seeing the evidence if your hypothesis is true. It measures how well the hypothesis explains the evidence.

3. Marginal likelihood, P(B): This is the total probability of seeing the evidence under all possible scenarios, whether your hypothesis is true or false.

4. Posterior probability, P(A | B): This is the result of the calculation. It is the updated probability of your hypothesis after you include the new evidence.

To see why the math works, start with the rule for the probability that two events, A and B, both happen. We write this as P(A and B). For both to happen, A must happen first, and then B must happen given A. Therefore, you multiply their probabilities:

P(A and B) = P(A) × P(B | A)

Order does not change the reality that both events happened. The probability of "rain and wet ground" is the same as the probability of "wet ground and rain." You can also calculate it by starting with B:

P(A and B) = P(B) × P(A | B)

Because both equations equal P(A and B), they equal each other:

P(B) × P(A | B) = P(A) × P(B | A)

When you divide both sides by P(B), you get Bayes' theorem.

The top of the fraction, P(B | A) × P(A), is the probability that your hypothesis is true and produces the evidence. The bottom, P(B), is the probability of the evidence from all possible causes. You often calculate P(B) with the law of total probability: you add the chance of the evidence when A is true to the chance of the evidence when A is false. Bayes' theorem simply finds what share of all possible ways to get the evidence comes from your specific hypothesis.

Fact-checked against Bayes' theorem on Wikipedia

Part of the Mathematics syllabus: Probability and Statistical Inference

See it on the timeline of Probability and Statistical Inference