Spring 2026, UC Berkeley
Our next topic is Bayesian computation. The two main classes of techniques are Markov Chain Monte Carlo (MCMC) and Variational Inference (VI). We will start discussing MCMC today.
Markov Chain Monte Carlo¶
The goal is to obtain samples from a target distribution with density (in our applications, will be the posterior density). We assume that is known only upto a normalizing constant. The normalizing constant can be determined by integrating the unnormalized (over its domain) but this integration is assumed to be difficult.
We want to generate such that
for all functions .
is generated sequentially or iteratively for with (and some external randomness) used to generate .
The simplest MCMC algorithm is the Random Walk Metropolis Algorithm.
The Random Walk Metropolis Algorithm¶
The random-walk Metropolis algorithm works by generating proposals via a random walk-step from the current state and then accepting or rejecting them with certain probability. Suppose that the current state is . It then proposes to move to the state where is a random vector having a symmetric density around 0. Note that the density of the proposal is given by where
with denoting the density of . Because is symmetric about 0, we have
The function is commonly referred to as the candidate-generating density or proposal-generating density. We say that is symmetric if (2) holds. Clearly random walk Metropolis with a symmetric uses symmetric proposal-generating densities. With this notation, the random-walk Metropolis algorithm can be rephrased as follows. For and , let
is referred to as the acceptance probability while going from to .
Initialize with an arbitrary value .
Repeat the following for :
Let .
Generate a candidate or proposal from the symmetric candidate generating density and a uniform random number .
If , then set . We say in this case that the proposed move from to is rejected and we stay at .
If , then set . We say in this case that the proposed move from to is accepted.
Return the values .
The above algorithm is known as the Metropolis Algorithm. It works for any symmetric (i.e., satisfying (2)) proposal-generating density . The Random-Walk Metropolis algorithm is a special case of this where is of the form for a symmetric (about 0) density .
The Metropolis algorithm can be further generalized to deal with non-symmetric proposal generating densities. This generalization is referred to as the Metropolis-Hastings algorithm. We shall look at this algorithm in the next lecture. We will try to answer the following questions in the coming lectures:
What is the intuition behind the form of these algorithms?
Why do they actually work and give samples satisfying (1)?
To answer these questions, we need to know a little bit about Markov Chains. The algorithms above output samples . Clearly, is generated using only the value . In other words, the values are not used at all in order to generate . Thus can be seen as a realization of a sequence of random vectors which form a Markov Chain. Properties of Markov Chains are used to justify (1), as we shall see in the coming lectures.