Lesson 1.7core3 h 30 min⚡ live demo

Probability II: Bayes, independence, MLE and MAP

Updating beliefs, and why minimizing a loss is maximizing a likelihood

Two ideas from this lesson run the whole path. Bayes' theorem is how evidence updates belief — it is the logic of classifiers (3.7 Naive Bayes and generative vs discriminative models), of posterior inference in VAEs (8.8 Generative models I: VAEs and GANs) and of every "given the context, what is the next token" computation (7.6 Decoder-only: GPT and autoregressive generation). Maximum likelihood is why the loss functions of Phase 4 look the way they do: squared error, binary cross-entropy and cross-entropy are each the negative log-likelihood of a distribution, and regularization is a prior (3.6 Regularization and generalization). After this lesson, no loss function will ever look arbitrary again.

You'll be able to

  • Manipulate joint, marginal and conditional probabilities with the sum, product and chain rules
  • Apply Bayes' theorem to a diagnostic problem and explain the base-rate fallacy
  • Derive maximum-likelihood estimates for Bernoulli and Gaussian models, and explain MAP as MLE plus a prior
  • Show that negative log-likelihood under Gaussian, Bernoulli and Categorical models gives MSE, BCE and cross-entropy

Key ideas

  1. Sum rule marginalizes, product rule conditions, and the chain rule p(x₁…xₙ) = Π p(xₜ | x₍<ₜ₎) is the language-model factorization.
  2. Independence: p(x, y) = p(x)p(y); conditional independence given z underlies i.i.d. data and naive Bayes.
  3. Bayes: posterior ∝ likelihood × prior; a 99%-sensitive, 95%-specific test at 1% prevalence gives only a 16.7% posterior — the base-rate fallacy.
Show 5 more key ideas
  1. Likelihood treats the data as fixed and ranks parameters; log-likelihoods of i.i.d. data are sums.
  2. MLE: Bernoulli p̂ = k/n; Gaussian μ̂ = mean, σ̂² = (1/n)Σ(xᵢ − x̄)² (slightly biased).
  3. MAP = MLE + log prior: Beta priors are pseudo-counts (Laplace smoothing); Gaussian priors are ℓ₂ weight decay, Laplace priors are ℓ₁.
  4. Loss = negative log-likelihood: Gaussian → MSE, Bernoulli → BCE, Categorical → cross-entropy, Laplace → MAE. Choosing a loss is choosing a noise model.
  5. Multivariate Gaussian: Mahalanobis distance, ellipsoidal level sets from Σ's eigen-decomposition, sampling via x = μ + Lz.

Suggested path through this lesson