Markov chain Monte Carlo sampling algorithms

Lecture 2

Dr Samuel Livingstone

Last time

Today - towards more advanced sampling algorithms!

Part 1: Motivation

The need for better sampling algorithms

Rejection sampling example (1)

Rejection sampling example (2)

Some remarks

Bayesian inference refresh

Bayes in a nutshell

Bayes: an example (1)

Bayes: an example (2)

Bayes: an example

par(mfrow = c(1,2))

n <- 10
f1 <- function(x) { dbeta(x, shape1 = 1, shape2 = 1) }
f2 <- function(x) { dbeta(x, shape1 = 1+n, shape2 = 1) }

curve(f1, from = 0, to = 1, main = "Prior", xlab = "p", ylab = "Density", ylim = c(0,10))
curve(f2, from = 0, to = 1, main = "Posterior", xlab = "p", ylab = "", ylim = c(0,10))

Bayes: another example

There are pros and cons to Bayes, just like any other approach!

How to integrate with respect to a high-dimensional unnormalised posterior?

Part 2: General state space Markov chains

Markov chain

Definition An \(E\)-valued discrete-time stochastic process \(\{X_{t}\}_{t\geq0}\) is called a Markov chain if for any fixed \(t\) and any \(x_{t}\in E\) the random variable \[ X_{t+1}|(X_{t}=x_{t}) \] is independent of \(X_{t-k}\) for all \(t \geq k \geq 1\).

To simulate a Markov chain, we need only two things

Example (finite state space)

Let \(X_0 = 1\) or \(2\) w.p. \(1/2\), and introduce the matrix

\[ \bar{P} = \left( \begin{array}{cc} 1/3 & 2/3 \\ 2/3 & 1/3 \end{array}\right). \]

Example (finite state space)

Example (continuous state space)

Example (continuous state space, \(X_0 = 20\), \(\gamma = 0.8\))

Remark

Marginal distributions

Calculating marginal distributions: Example 1

Calculating marginal distributions: Example 2

Finite state space example re-visited

Forgetting the initial state

Measuring the distance between distributions

Convergence to equilibrium

More properties of Markov chains

Example of \(\pi\)-invariance

Theorem: convergence to equilibrium

If a Markov chain with transition kernel \(P\) is \(\pi\)-invariant, \(\pi\)-irreducible and aperiodic, then \(\pi\) is the unique limiting distribution for the chain.

Checking the conditions

\(\pi\)-reversibility

Example (re-visited again)

Theorem (reversibility \(\implies\) invariance)

The Markov chain ergodic theorem

If a Markov chain \(\{X_{t}\}_{t\geq0}\) is \(\pi\)-irreducible and \(\pi\)-invariant, and \(f: E \to\mathbb{R}\) satisfies \(\mathbb{E}_{\pi}[f(X)]<\infty\), then the ergodic average \[ \hat{f}_{n}:= \frac{1}{n}\sum_{i=0}^{n-1}f(X_{i}) \] satisfies \[ \mathbb{P}\left(\lim_{n\to\infty}\hat{f}_{n}=\mathbb{E}_{\pi}[f(X)]\right)=1. \]

Part 3: Markov chain Monte Carlo (1 slide)

Markov chain Monte Carlo (basic idea)

End of lecture

We will find out next time!