Bayes’ Theorem

How to update a belief with new evidence, and why gut feeling fails on rare events.

🟢 beginner4 min readprobabilitybayesian
Bayes' theorem tells you how to update a belief when new evidence arrives. You start with how likely something was before, then adjust it by how well the evidence fits. The classic interview trap is the rare disease test. If only one person in a thousand has the disease, a test that is 99 percent accurate still flags far more healthy people than sick ones, simply because healthy people vastly outnumber the sick. In ML, the same idea powers Naive Bayes and Bayesian optimisation.

The formula and its components

Bayes' Theorem decomposes conditional probability into four distinct terms:

P(A | B) = [ P(B | A) · P(A) ] / P(B)

Posterior = [ Likelihood · Prior ] / Evidence

Base rate fallacy: Why human intuition fails

When testing for rare events (fraud, rare disease, network intrusions), the prior base rate P(A) dominates the posterior calculation.

MetricValueMeaning
Base Rate P(Disease)0.1% (1 in 1000)Rare prior event
Sensitivity P(+ | Disease)99%Low false negatives
Specificity P(- | No Disease)99%Low false positive rate (1%)

For 100,000 tested individuals:

Posterior P(Disease | +) = 99 / (99 + 999) ≈ 9.0%. Even with 99% test accuracy, 91% of positive results are false alarms because the prior is so small.

Where Bayes appears in ML rounds

  1. Naive Bayes Classifiers: Assumes feature independence given class: P(Y|X) ∝ P(Y) ∏ P(X_i|Y). Fast baseline for NLP and spam filtering.
  2. MAP vs MLE: MAP adds a prior term to parameter estimation argmax_θ P(X|θ)P(θ). Adding a Gaussian prior over weights is mathematically equivalent to L2 regularization (Ridge).
  3. Bayesian Optimization: Fits a Gaussian Process prior over an expensive objective function (hyperparameter search) to balance exploration and exploitation via acquisition functions (Expected Improvement, UCB).

Say this out loud

"Bayes’ Theorem updates prior beliefs with new evidence. In real-world systems, ignoring the base rate leads to massive overconfidence — a 99% accurate test on a 0.1% rare event still yields ~91% false positives. In ML, Bayes connects regularization to priors: MAP estimation with a Gaussian prior is equivalent to L2 regularization, while a Laplacian prior gives L1."

Follow-ups to expect

Check yourself

Question 1 of 3

A disease affects 1 in 1,000 people. A test is 99% accurate (99% sensitivity, 99% specificity). If a random person tests positive, the probability they actually have the disease is closest to

More in Math & Statistics

See all →
Central Limit Theorem4 minLaw of Large Numbers4 minExpectation & Variance4 min