Bayes' Theorem Formula

The Formula

P(Amid B)= rac{P(Bmid A)P(A)}{P(B)}

When to use: Start with a prior belief, then reweight it by how likely the evidence is under each hypothesis.

Quick Example

A disease test is 99% accurate; 1% of people have the disease. If you test positive, P(\text{disease}|+) \approx 50\% โ€” not 99%, because the disease is rare.

Notation

P(A) prior, P(Bmid A) likelihood, P(Amid B) posterior.

What This Formula Means

Bayes' theorem gives the posterior probability of a hypothesis given evidence: P(H|E) = \frac{P(E|H) \cdot P(H)}{P(E)}.

Start with a prior belief, then reweight it by how likely the evidence is under each hypothesis.

Formal View

For events A and B with P(B) > 0: P(A|B) = \frac{P(B|A) \cdot P(A)}{P(B)} where P(B) = P(B|A)P(A) + P(B|A^c)P(A^c) by the law of total probability.

Worked Examples

Example 1

medium
Email spam filter: P(\text{spam})=0.3. The word 'free' appears in 80% of spam emails and 10% of legitimate emails. An email contains 'free'. Find P(\text{spam}|\text{free}) using Bayes' theorem.

Solution

  1. 1
    Prior: P(\text{spam})=0.3, P(\text{legit})=0.7
  2. 2
    Likelihoods: P(\text{free}|\text{spam})=0.8, P(\text{free}|\text{legit})=0.1
  3. 3
    Law of total probability: P(\text{free}) = 0.8(0.3) + 0.1(0.7) = 0.24 + 0.07 = 0.31
  4. 4
    Bayes: P(\text{spam}|\text{free}) = \frac{P(\text{free}|\text{spam}) \times P(\text{spam})}{P(\text{free})} = \frac{0.8 \times 0.3}{0.31} = \frac{0.24}{0.31} \approx 0.774

Answer

P(\text{spam}|\text{free}) \approx 0.774. There's a 77.4% chance the email is spam.
Bayes' theorem updates the prior probability (30% base spam rate) with new evidence (email contains 'free') to get a posterior probability (77.4%). This is how Bayesian spam filters work โ€” each word updates the probability that an email is spam.

Example 2

hard
Drug testing: P(\text{user})=0.05. Test sensitivity P(+|\text{user})=0.99. Specificity P(-|\text{non-user})=0.95 (so P(+|\text{non-user})=0.05). Find P(\text{user}|+).

Common Mistakes

  • Confusing P(A|B) with P(B|A) โ€” the probability of having a disease given a positive test is NOT the same as the probability of testing positive given the disease
  • Forgetting to compute the total probability P(B) using the law of total probability, which accounts for both P(B|A) and P(B|A^c)
  • Ignoring the base rate (prior probability) โ€” a rare disease with a 99% accurate test still yields many false positives when the prior is very low

Why This Formula Matters

Bayes' theorem is the foundation of modern probabilistic reasoning, powering spam filters, medical diagnostics, and machine learning. It teaches us how to rationally update our beliefs when we receive new evidence, which is critical in fields from epidemiology to courtroom forensics.

Frequently Asked Questions

What is the Bayes' Theorem formula?

Bayes' theorem gives the posterior probability of a hypothesis given evidence: P(H|E) = \frac{P(E|H) \cdot P(H)}{P(E)}.

How do you use the Bayes' Theorem formula?

Start with a prior belief, then reweight it by how likely the evidence is under each hypothesis.

What do the symbols mean in the Bayes' Theorem formula?

P(A) prior, P(Bmid A) likelihood, P(Amid B) posterior.

Why is the Bayes' Theorem formula important in Math?

Bayes' theorem is the foundation of modern probabilistic reasoning, powering spam filters, medical diagnostics, and machine learning. It teaches us how to rationally update our beliefs when we receive new evidence, which is critical in fields from epidemiology to courtroom forensics.

What do students get wrong about Bayes' Theorem?

The base rate (prior probability P(H)) is the most commonly neglected factor โ€” ignoring it leads to the base-rate fallacy and wildly overconfident conclusions.

What should I learn before the Bayes' Theorem formula?

Before studying the Bayes' Theorem formula, you should understand: conditional probability, probability, sample space.