7 routes42 sections324 units

Unit 3.5 · about 4 h

69 / 324

Bayes rule, conjugate priors and posterior predictives

Posterior prediction is the honest form of a probabilistic forecast: it carries parameter uncertainty into the prediction instead of plugging in a point estimate.

  • derive
  • implement

You can now

  • Explain prior, likelihood, posterior, evidence, posterior predictive and credible interval, and how each differs from its frequentist lookalike.
  • Derive a Beta-Binomial conjugate posterior and its posterior predictive distribution, stating every modeling assumption.
  • Factor a small joint distribution from a stated graph and run a prior-sensitivity check by repeated simulation.

Covers

  • Bayes rule, likelihood, evidence and posterior
  • Priors, conjugacy, posterior predictive distributions and sensitivity
  • Simple graphical factorization and latent variables

Study, in this order

4 steps

  1. Bayesian updating with discrete priors and prediction
    MIT 18.05 - Bayesian bridge

    Class 11 reading: Bayesian Updating with Discrete Priors, with its Bayes tables; Class 12a reading: Probabilistic Prediction

  2. Continuous priors, conjugate priors and prior choice
    MIT 18.05 - Bayesian bridge

    Class 13a reading: Bayesian Updating with Continuous Priors; Class 15 reading: Conjugate Priors, Beta and Normal; Class 16a and 16b readings: Choosing Priors and Probability Intervals

  3. Hybrid Bayes rule and Beta-Binomial updating
    Harvard Stat 110 - Probability

    Lecture 17: hybrid Bayes rule and Laplace succession; Lecture 23: Beta distribution and Bayes billiards

  4. Beta-Binomial posterior and posterior predictive
    Probabilistic Machine Learning: An Introduction

    Chapter 4, Sections 4.6.1-4.6.2.10 (pp. 129-136): conjugate priors, Beta-Binomial posterior, MAP, posterior predictive and marginal likelihood

    Depth · Stop before Section 4.6.2.11 (mixtures of conjugate priors). The Dirichlet and Gaussian models and the computation methods of Section 4.6.8 belong to later stages.

Focus on

  • Conjugacy is algebra: a Beta prior times a Binomial likelihood is Beta up to a constant. The update adds successes to \(a\) and failures to \(b\).
  • The posterior predictive averages over the posterior; the plug-in forecast conditions on one estimate. They differ most with little data.
  • The evidence normalizes the posterior for fixed data and compares models across hypotheses. It never rescales a single posterior's shape.
  • A graphical factorization is a chain-rule product with dropped conditioning bars. Each dropped bar is a conditional-independence claim to defend.

Reproduce closed-book

Closed-book, derive the Beta-Binomial update for a \(\operatorname{Beta}(2, 2)\) prior with 7 heads in 10 flips: posterior \(\operatorname{Beta}(9, 5)\), mean \(9/14=0.6429\), MAP \(8/12=0.6667\), posterior predictive \(P(\text{next head})=9/14\). Check with NumPy in float64: numpy.random.default_rng(41), 300000 beta(9, 5) draws; posterior mean 0.6430 with standard error 0.00023, one binomial(1, theta) flip per draw from the same generator gives predictive fraction 0.6439, and the 2.5 and 97.5 percent sample quantiles give the 95 percent credible interval [0.385, 0.862] (exact \(\operatorname{Beta}(9, 5)\) quantiles 0.386 and 0.861).

Traps

  • Reporting the MAP as the posterior mean. For a \(\operatorname{Beta}(a, b)\) posterior they coincide only when \(a=b\); here 0.6667 differs from 0.6429.
  • Reading a 95 percent credible interval as a 95 percent confidence interval. One conditions on the observed data with a prior; the other is a pre-data coverage statement.
  • Reusing the same data to pick the prior and to update. That double counts the evidence; run a prior-sensitivity check instead.

Practice

MIT 18.05 Problem Set 7: Problems 2 and 6

Problem 2 (Prediction: prior, posterior and posterior predictive) and Problem 6 (Normal-Normal conjugate updating); official solutions are linked beside the set with the same problem numbers

Attempt both before opening the solutions. Problem 2 is the closest match to this unit's implement target.

Deep-ML 336: Compute Posterior Probability using Bayes Theorem

Implement bayes_theorem(priors, likelihoods); the two tests check the normalized prior-times-likelihood posterior to 4 decimals

The function is a discrete Bayes table. Check it against your hand table for Problem Set 7, Problem 2(a), then contrast it with the conjugate update, which needs no table.

Self-test

  1. Derive the \(\operatorname{Beta}(9, 5)\) posterior from Bayes rule and name the step that uses conjugacy.

  2. Derive the posterior predictive 9/14 and state the assumption that lets the integral close.

  3. How does the predictive probability move if the prior changes from \(\operatorname{Beta}(2, 2)\) to \(\operatorname{Beta}(20, 20)\) with the same 7-in-10 data?

  4. A two-node graph \(X \to Y\) claims \(p(x, y)=p(x)p(y \mid x)\). What does the missing bar encode?

Completion criterion

Stop when

You derive the \(\operatorname{Beta}(9, 5)\) posterior, its mean, MAP and predictive without notes, your rerun of the seed-41 check matches the posterior mean to 3 decimals, and you can show how a stronger prior moves the predictive.

Mark passed, then open 3.6 Only mark this when you can do it without notes.

Leads to

Comes after

Resources for this unit

  • Harvard Stat 110 - Probability
    Harvard Universityprimarycourse
    Follow lectures 4-14, 17-23 and 25-30 with matching Strategic Practice. Use lectures 1-3 only for prerequisite repair.
  • MIT 18.05 - Bayesian bridge
    MIT OpenCourseWarerequiredcourse
    Use classes 10-16 for MLE, Bayesian updating, posterior prediction, conjugacy, prior choice and credible intervals.
  • Probabilistic Machine Learning: An Introduction
    Kevin Murphyreferencetheory
    Consult targeted parts of Chapters 2, 3, 4 and 6 for ML notation, Monte Carlo, factorization, posterior prediction and information theory.

Also in this section

  • Stat 110 Strategic Practice
    Harvard Universityrequiredpractice
    Solve the matching sets before marking a probability topic Practised; use solutions to audit reasoning, not to begin it.
  • D2L - Information Theory
    D2L authorsrequiredimplementation
    Use §§22.11.1-22.11.5 for runnable entropy, cross-entropy, KL and mutual-information examples and exercises.

Quick find

Search Michi

Type to search every route, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels