University of Southampton · FACULTY OF STATISTICS

MATH6174 Chap.10 Bayesian Computation and Markov Chain Monte Carlo

- one subject, every graph, every model, every mark
7 Chapters3-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 10 of 10 · MATH6174

Bayesian Computation and Markov Chain Monte Carlo

Bayesian Computation and Markov Chain Monte Carlo deals with the posteriors that cannot be handled by recognising a kernel. Every posterior summary, whether a mean, a probability or a predictive value, is an integral against the posterior, and outside the conjugate cases those integrals rarely have a closed form. The lecture notes give a sequence of remedies.

Numerical integration with a grid rule such as the trapezoidal rule works well in one to three dimensions but becomes impractical as the dimension grows. The Laplace approximation replaces the posterior by a normal distribution centred at its mode, with variance matrix given by the inverse of minus the Hessian of the log posterior there; it is accurate for large samples.

Monte Carlo integration averages a function over random draws from the posterior, and the law of large numbers makes that average converge to the integral. When direct draws are not available, rejection sampling proposes from an easy density under an envelope and keeps each proposal with probability equal to the target over the envelope.

Importance sampling weights draws from a convenient density by the ratio of target to proposal, and the weighted bootstrap resamples them with those weights. For high-dimensional problems Markov chain Monte Carlo constructs a Markov chain whose stationary distribution is the posterior. The Gibbs sampler updates one component at a time from its full conditional distribution.

The Metropolis-Hastings algorithm proposes a move from a proposal distribution and accepts it with a probability that needs the target only up to its normalising constant. The notes end with implementation issues: trace plots, autocorrelations, several starting points and the warning that diagnostics are evidence of no obvious problem rather than proof of convergence.

In this chapter

What this chapter covers

  • 01

    Posterior summaries as integrals

  • 02

    Grid rules and the trapezoidal method

  • 03

    The Laplace approximation at the posterior mode

  • 04

    Monte Carlo integration and the law of large numbers

  • 05

    Rejection sampling under an envelope

  • 06

    Importance sampling and the weighted bootstrap

  • 07

    Gibbs sampling, Metropolis-Hastings and convergence diagnostics

Worked example · free

Estimate a posterior probability by Monte Carlo and give its standard error

Q [4 marks]. A simulation draws N = 2,000 values from a posterior, and 340 of them exceed a threshold c. Estimate the posterior probability that the parameter exceeds c and give a Monte Carlo standard error. Marks here are for practice and do not come from the university.
A random-walk chain finding the posterior.A random-walk chain finding the posterior. A computed Metropolis-Hastings run for the gamma(18, 7) target, plotted by iteration and started far out at 6; it drifts down within the shaded burn-in, then wanders around the posterior mean, accepting 79% of proposals with a post burn-in average of 2.43.050100150200250300123456iterationlambdaburn-in: the first 50 draws are discardedposterior mean 18/7 = 2.57
A random-walk chain finding the posterior. A computed Metropolis-Hastings run for the gamma(18, 7) target, plotted by iteration and started far out at 6; it drifts down within the shaded burn-in, then wanders around the posterior mean, accepting 79% of proposals with a post burn-in average of 2.43.
  • 1Write the probability as an expectation of an indicator, so the Monte Carlo estimate is the sample proportion 340/2000 = 0.17.
  • 1Each indicator is Bernoulli with variance p(1 - p), so the estimator has variance p(1 - p)/N.
  • 1Plugging in 0.17 gives 0.17 times 0.83 divided by 2000, which is 0.0000706, and a standard error of about 0.0084.
  • 1The simulation error is small next to the estimate, so more draws would change the second decimal place only slightly.
The posterior probability is estimated as 0.17 with Monte Carlo standard error about 0.008.
Sia tip — Turn any probability into the mean of an indicator before simulating; the standard error then follows from the Bernoulli variance.
Glossary

Key terms

Laplace approximation
A normal approximation to a posterior centred at its mode with variance from the curvature of the log posterior.
Rejection sampling
A method that keeps proposals from an envelope density with probability equal to the target over the envelope.
Importance sampling
A method that estimates expectations by weighting draws from a proposal density by target over proposal.
Gibbs sampler
A Markov chain sampler that updates each component in turn from its full conditional distribution.
Burn-in period
The early iterations of a Markov chain that are discarded before its output is used for estimates.
FAQ

Bayesian Computation and Markov Chain Monte Carlo FAQ

Why does Metropolis-Hastings not need the normalising constant?

The target enters only through the ratio of its values at the proposed and current points. Any constant factor cancels in that ratio, so the posterior can be used up to proportionality, which is exactly how it is usually known.

When is the Laplace approximation good?

It works well when the posterior is close to normal, which typically happens with large samples and a unimodal, smooth log posterior. For a small sample or a strongly skewed posterior, such as a gamma with small shape, the mean and variance it gives can be noticeably off.

How do I choose an envelope for rejection sampling?

Pick a density you can sample from whose shape is close to the target, then choose the smallest constant M that keeps M times the envelope above the target everywhere. The acceptance rate is one over M, so a tighter envelope wastes fewer proposals.

Can a convergence diagnostic prove that a chain has converged?

No. The lecture notes are explicit that diagnostics such as trace plots, autocorrelations and runs from different starting points are evidence that there are no obvious problems, not a proof. Multi-modal targets in particular can look converged from a single start.

Study strategy

Exam move

Write each algorithm as a short numbered list from memory: trapezoidal rule, Laplace approximation, rejection sampling, importance sampling, Gibbs and Metropolis-Hastings. For each, add one line on what it needs, such as a mode and Hessian, an envelope constant or full conditionals. Then practise one Laplace approximation and one Metropolis acceptance probability by hand, and explain the convergence checks in two sentences.

Working through Bayesian Computation and Markov Chain Monte Carlo in MATH6174? Sia is AskSia’s AI Statistics tutor — ask any MATH6174 Bayesian Computation and Markov Chain Monte Carlo question and get a clear, step-by-step explanation grounded in how MATH6174 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 8 of your subjects at University of Southampton, plus 1,000+ more Bibles across the AskSia library.
Sia - your MATH6174 tutor, unlimited, worked the way the exam marks it
The full 3-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works