# Introduction to Sequential Monte Carlo Methods

These notes are based on the following article:

Doucet, Arnaud, Nando de Freitas, and Neil Gordon (2001): “An Introduction to Sequential Monte Carlo Methods,” in Sequential Monte Carlo Methods in Practice, ed. by A. Doucet, N. de Freitas, and N. Gordon. New York: Springer-Verlag.

## Introduction

Real-world data analysis often requires estimating unknown quantities given only a sequence of observations on some related observable quantity. In a Bayesian framework, one typically has a priori knowledge of the model: a prior distribution of the unobservable quantity of interest and likelihood functions which relate the observables to the unobservables. The resulting posterior distribution of the unobservables can be calculated using Bayes’ theorem. This allows one to conduct inference about the unobserved quantities.

In some cases, it is natural to process observations sequentially. These cases are the focus of this introductory article and the rest of the book. For example, on-line applications such as radar tracking or estimating financial instruments where new data become available in real time, it is easier to update the previously formed posterior distribution than to recalculate it from scratch.

Sequential Monte Carlo methods are simulation-based methods for calculating approximations to posterior distributions. They avoid making linearity or normality assumptions required by related methods such as the Kalman filter.

## Model

Let $\left\{{x}_{t}{\right\}}_{t=0}^{\infty }$ denote the sequence of unobserved states, with ${x}_{t}\in 𝒳$. The authors consider only the case when $\left\{{x}_{t}\right\}$ is a Markov process with initial distribution $p\left({x}_{0}\right)$. The Markov assumption is not needed and is only for tractability. Let $p\left({x}_{t}|{x}_{t-1}\right)$ denote the transition equation. Let $\left\{{y}_{t}{\right\}}_{t=1}^{\infty }$ denote a sequence of observations with ${y}_{t}\in 𝒴$. Suppose that, given $\left\{{x}_{t}\right\}$, the observations are conditionally independent. Let $p\left({y}_{t}|{x}_{t}\right)$ denote the marginal distribution, or the observation equation.

Thus, the model is defined by the following distributions: $\begin{array}{c}p\left({x}_{0}\right),\\ p\left({x}_{t}|{x}_{t-1}\right)\phantom{\rule{1em}{0ex}}\text{for}\phantom{\rule{1em}{0ex}}t\ge 1,\\ p\left({y}_{t}|{x}_{t}\right)\phantom{\rule{1em}{0ex}}\text{for}\phantom{\rule{1em}{0ex}}t\ge 1.\end{array}$

Define ${x}_{0:t}\equiv \left\{{x}_{0},\dots ,{x}_{t}\right\}$ and ${y}_{0:t}\equiv \left\{{y}_{1},\dots ,{y}_{t}\right\}$. Our goal is to estimate the posterior distribution $p\left({x}_{0:t}|{y}_{1:t}\right)$ recursively. We also may care about the marginal distribution $p\left({x}_{t}|{y}_{1:t}\right)$ or an expectation such as $I\left({h}_{t}\right)\equiv E\left[{h}_{t}\left({x}_{0:t}\right)|{y}_{1:t}\right]=\int {h}_{t}\left({x}_{0:t}\right)p\left({x}_{0:t}|{y}_{1:t}\right)\phantom{\rule{thinmathspace}{0ex}}{\mathrm{dx}}_{0:t}$ for some ${h}_{t}:{𝒳}^{t}\to {ℝ}^{n}$ that is integrable with respect to $p\left({x}_{0:t}|{y}_{1:t}\right)$.

Bayes’ theorem gives us the posterior distribution at any time $t$: $p\left({x}_{0:t}|{y}_{1:t}\right)=\frac{p\left({y}_{1:t}|{x}_{0:t}\right)p\left({x}_{0:t}\right)}{\int p\left({y}_{1:t}|{x}_{0:t}\right)p\left({x}_{0:t}\right)\phantom{\rule{thinmathspace}{0ex}}{\mathrm{dx}}_{0:t}}$

There is an inherent recursive relationship for updating the posterior distribution. We can express $p\left({x}_{0:t+1}|{y}_{0:t+1}\right)$ in terms of $p\left({x}_{0:t}|{y}_{1:t}\right)$: $\begin{array}{rl}p\left({x}_{0:t+1}|{y}_{1:t+1}\right)& =\frac{p\left({x}_{0:t+1},{y}_{1:t+1}\right)}{p\left({y}_{1:t+1}\right)}\\ & =\frac{p\left({x}_{t+1},{y}_{t+1}|{x}_{0:t},{y}_{0:t}\right)p\left({x}_{0:t},{y}_{1:t}\right)}{p\left({y}_{t+1}|{y}_{1:t}\right)p\left({y}_{1:t}\right)}\\ & =\frac{p\left({y}_{t+1}|{x}_{t+1}\right)p\left({x}_{t+1}|{x}_{t}\right)}{p\left({y}_{t+1}|{y}_{1:t}\right)}p\left({x}_{0:t}|{y}_{1:t}\right)\\ \end{array}$ where the last equality uses the definition of the conditional density, the conditional independence assumption, and the Markov assumption. The expression in the denominator is constant with respect to ${x}_{0:t+1}$.

## Perfect Monte Carlo Sampling

In the ideal situation, we could draw a sample of size $N$ from $p\left({x}_{0:t}|{y}_{1:t}\right)$, the posterior distribution of interest. Call this sample $\left\{{x}_{0:t}^{\left(i\right)}{\right\}}_{i=1}^{N}$. We can form an estimate of $p\left({x}_{0:t}|{y}_{1:t}\right)$ using the empirical distribution of the sample: ${P}_{N}\left({\mathrm{dx}}_{0:t}|{y}_{0:t}\right)={N}^{-1}\sum _{i=1}^{N}{\delta }_{{x}_{0:t}^{\left(i\right)}}\left({\mathrm{dx}}_{0:t}\right).$ From here, we can estimate the integral $I\left({h}_{t}\right)$ by $\int {h}_{t}\left({x}_{0:t}\right){P}_{N}\left({\mathrm{dx}}_{0:t}|{y}_{1:t}\right)={N}^{-1}\sum _{i=1}^{N}{h}_{t}\left({x}_{0:t}^{\left(i\right)}\right).$

Typically it is impossible to get such a sample since $p\left({x}_{0:t}|{y}_{1:t}\right)$ is multivariate, known only up to a constant of proportionality, and non-standard. Markov chain Monte Carlo methods may be used in similar situations, but they are not well-suited to recursive problems such as the ones considered here.

## Importance Sampling

Since we can’t draw from $p\left({x}_{0:t}|{y}_{1:t}\right)$ directly, we can use importance sampling to draw from $p\left({x}_{0:t}|{y}_{1:t}\right)$ indirectly using an importance sampling density $\pi \left({x}_{0:t}|{y}_{1:t}\right)$ and a corresponding importance weight for each draw. The importance sampling density must be chosen so that its support includes the support of $p\left({x}_{0:t}|{y}_{1:t}\right)$. We have $\begin{array}{rl}I\left({h}_{t}\right)\equiv E\left[{h}_{t}\left({x}_{0:t}\right)|{y}_{1:t}\right]& =\int {h}_{t}\left({x}_{0:t}\right)p\left({x}_{0:t}|{y}_{1:t}\right)\phantom{\rule{thinmathspace}{0ex}}{\mathrm{dx}}_{0:t}\\ & =\frac{\int {h}_{t}\left({x}_{0:t}\right)p\left({x}_{0:t}|{y}_{1:t}\right)\phantom{\rule{thinmathspace}{0ex}}{\mathrm{dx}}_{0:t}}{\int p\left({x}_{0:t}|{y}_{1:t}\right)\phantom{\rule{thinmathspace}{0ex}}{\mathrm{dx}}_{0:t}}\\ & =\frac{\int {h}_{t}\left({x}_{0:t}\right)w\left({x}_{0:t}\right)\pi \left({x}_{0:t}|{y}_{1:t}\right)\phantom{\rule{thinmathspace}{0ex}}{\mathrm{dx}}_{0:t}}{\int w\left({x}_{0:t}\right)\pi \left({x}_{0:t}|{y}_{1:t}\right)\phantom{\rule{thinmathspace}{0ex}}{\mathrm{dx}}_{0:t}}\end{array}$ where $w\left({x}_{0:t}\right)\equiv \frac{p\left({x}_{0:t}|{y}_{1:t}\right)}{\pi \left({x}_{0:t}|{y}_{1:t}\right)}$ is the importance weight.

Thus, to approximate the expectation $I\left({h}_{t}\right)$, we simply need to draw a sample $\left\{{x}_{0:t}^{\left(i\right)}{\right\}}_{i=1}^{N}$ from $\pi \left({x}_{0:t}|{y}_{1:t}\right)$ and calculate $I\left({h}_{t}\right)=\frac{{N}^{-1}\sum _{i}{h}_{t}\left({x}_{0:t}\right)w\left({x}_{0:t}^{\left(i\right)}\right)}{{N}^{-1}\sum _{i}w\left({x}_{0:t}^{\left(i\right)}\right)}=\sum _{i}{h}_{t}\left({x}_{0:t}\right){\stackrel{˜}{w}}_{t}^{\left(i\right)}$ where ${\stackrel{˜}{w}}_{t}^{\left(i\right)}\equiv \frac{w\left({x}_{0:t}\right)}{\sum _{j}w\left({x}_{0:t}^{\left(j\right)}\right)}$ are the normalized importance weights.

This procedure can be interpreted as a sampling method with an approximate posterior given by ${\stackrel{^}{P}}_{N}\left({\mathrm{dx}}_{0:t}|{y}_{1:t}\right)=\sum _{i}{w}_{t}^{\left(i\right)}{\delta }_{{x}_{0:t}}\left({\mathrm{dx}}_{0:t}\right).$ We can then approximate $I\left({h}_{t}\right)$ by $\stackrel{^}{I}\left({h}_{t}\right)=\int {h}_{t}\left({x}_{0:t}\right){\stackrel{^}{P}}_{N}\left({\mathrm{dx}}_{0:t}|{y}_{1:t}\right).$

Although this solves the problem of being able to obtain draws, this approach is still not well-suited for our recursive problem.

## Sequential Importance Sampling (SIS)

The goal of Sequential Importance Sampling (SIS) is to compute an estimate of $p\left({x}_{0:t}|{y}_{1:t}\right)$ using the past simulated values $\left\{{x}_{0:t-1}^{\left(i\right)}{\right\}}_{i=1}^{N}$. We have the following recursive representation of the importance sampling distribution: $\begin{array}{rl}\pi \left({x}_{0:t}|{y}_{1:t}\right)& =\pi \left({x}_{0}\right)\prod _{k=1}^{t}\pi \left({x}_{k}|{x}_{0:k-1},{y}_{0:k}\right).\end{array}$ This recursive relationship allows us to calculate the importance weights recursively: $\begin{array}{rl}w\left({x}_{0:t}\right)& \equiv \frac{p\left({x}_{0:t}|{y}_{1:t}\right)}{\pi \left({x}_{0:t}|{y}_{1:t}\right)}\\ & =\frac{p\left({x}_{0:t},{y}_{1:t}\right)}{p\left({y}_{1:t}\right)\pi \left({x}_{0:t-1}|{y}_{1:t-1}\right)\pi \left({x}_{t}|{x}_{0:t-1},{y}_{1:t}\right)}\\ & =\frac{p\left({x}_{0:t-1},{y}_{1:t-1}\right)p\left({x}_{t},{y}_{t}|{x}_{0:t-1},{y}_{1:t-1}\right)}{p\left({y}_{t}|{y}_{1:t-1}\right)p\left({y}_{1:t-1}\right)\pi \left({x}_{0:t-1}|{y}_{1:t-1}\right)\pi \left({x}_{t}|{x}_{0:t-1},{y}_{1:t}\right)}\\ & =\frac{p\left({x}_{0:t-1}|{y}_{1:t-1}\right)}{\pi \left({x}_{0:t-1}|{y}_{1:t-1}\right)}\frac{p\left({y}_{t}|{x}_{t}\right)p\left({x}_{t}|{x}_{0:t-1}\right)}{p\left({y}_{t}|{y}_{1:t-1}\right)\pi \left({x}_{t}|{x}_{0:t-1},{y}_{1:t}\right)}\\ & =w\left({x}_{0:t-1}\right)\frac{p\left({y}_{t}|{x}_{t}\right)p\left({x}_{t}|{x}_{0:t-1}\right)}{p\left({y}_{t}|{y}_{1:t-1}\right)\pi \left({x}_{t}|{x}_{0:t-1},{y}_{1:t}\right)}.\\ \end{array}$ Hence, $\begin{array}{rl}\stackrel{˜}{w}\left({x}_{0:t}^{\left(i\right)}\right)& =\frac{w\left({x}_{0:t}^{\left(i\right)}\right)}{\sum _{j}w\left({x}_{0:t}^{\left(j\right)}\right)}\\ & =\frac{w\left({x}_{0:t}^{\left(i\right)}\right)\frac{p\left({y}_{t}|{x}_{t}^{\left(i\right)}\right)p\left({x}_{t}^{\left(i\right)}|{x}_{0:t-1}^{\left(i\right)}\right)}{p\left({y}_{1:t}|{y}_{1:t-1}\right)\pi \left({x}_{t}^{\left(i\right)}|{x}_{0:t-1}^{\left(i\right)},{y}_{1:t}\right)}}{\sum _{j}w\left({x}_{0:t}^{\left(j\right)}\right)\frac{p\left({y}_{t}|{x}_{t}^{\left(j\right)}\right)p\left({x}_{t}^{\left(j\right)}|{x}_{0:t-1}^{\left(j\right)}\right)}{p\left({y}_{1:t}|{y}_{1:t-1}\right)\pi \left({x}_{t}^{\left(j\right)}|{x}_{0:t-1}^{\left(j\right)},{y}_{1:t}\right)}}.\end{array}$ Notice that the $p\left({y}_{t}|{y}_{1:t-1}\right)$ term is constant for all ${x}_{0:t}$ and cancels out.

A special case occurs when $\pi \left({x}_{0:t}|{y}_{1:t}\right)=p\left({x}_{0:t}\right)=p\left({x}_{0}\right)\prod _{k=1}^{k}p\left({x}_{k}|{x}_{k-1}\right)$ so that $w\left({x}_{0:t}\right)\propto w\left({x}_{0:t-1}\right)p\left({y}_{t}|{x}_{t}\right)$ and ${\stackrel{˜}{w}}_{t}^{\left(i\right)}\propto {w}_{t-1}^{\left(i\right)}p\left({y}_{t}|{x}_{t}^{\left(i\right)}\right).$

SIS is usually inefficient for high-dimensional integrals because as $t\to \infty$, the importance weights for some particles quickly approaches zero.

## The Bootstrap Filter

To prevent particle degeneracy, the bootstrap filter introduces a resampling step which eliminates particles with low importance weights. Instead of using the importance-weighted empirical distribution ${\stackrel{^}{P}}_{N}$ we use a uniformly-weighted distribution ${P}_{N}\left({\mathrm{dx}}_{0:t}|{y}_{1:t}\right)={N}^{-1}\sum _{i}{N}_{t}^{\left(i\right)}{\delta }_{{x}_{0:t}^{\left(i\right)}}\left({\mathrm{dx}}_{0:t}\right),$ where ${N}_{t}^{\left(i\right)}$ is the number of offspring of the particle ${x}_{0:t}^{\left(i\right)}$ which is to be determined by some branching mechanism. The most common such mechanism involves resampling $N$ times from ${\stackrel{^}{P}}_{N}$ (Gordon et al., 1993). We require ${\sum }_{i}{N}_{t}^{\left(i\right)}=N$ for all $t$. If ${N}_{t}^{\left(j\right)}=0$, the particle ${x}_{0:t}^{\left(j\right)}$ dies. We want to choose ${N}_{t}^{\left(i\right)}$ such that $\int {h}_{t}\left({x}_{0:t}\right){P}_{N}\left({\mathrm{dx}}_{0:t}|{y}_{1:t}\right)\approx \int {h}_{t}\left({x}_{0:t}\right){\stackrel{^}{P}}_{N}\left({\mathrm{dx}}_{0:t}|{y}_{1:t}\right).$ The surviving particles, those with ${N}_{t}^{\left(i\right)}>0$, are approximately distributed according to $p\left({x}_{0:t}|{y}_{1:t}\right)$.

### Algorithm

1. Initialization ($t=0$).

• For $i=1,\dots ,N$, draw ${x}_{0}^{\left(i\right)}\sim p\left({x}_{0}\right)$.
• Set $t←1$.
2. Importance Sampling Step

• For $i=1,\dots ,N$, draw ${\stackrel{˜}{x}}_{t}^{\left(i\right)}\sim p\left({x}_{t}|{x}_{t-1}^{\left(i\right)}\right)$ and set ${\stackrel{˜}{x}}_{0:t}^{\left(i\right)}←\left({x}_{0:t-1}^{\left(i\right)},{\stackrel{˜}{x}}_{t}^{\left(i\right)}\right)$.

• For $i=1,\dots ,N$, calculate the importance weights ${\stackrel{˜}{w}}_{t}^{\left(i\right)}=p\left({y}_{t}|{\stackrel{˜}{x}}_{t}^{\left(i\right)}\right)$ and normalize them.

3. Resampling Step

• Take $N$ draws $\left\{{x}_{0:t}^{\left(i\right)}{\right\}}_{i=1}^{N}$ with replacement from the set $\left\{{\stackrel{˜}{x}}_{0:t}^{\left(i\right)}{\right\}}_{i=1}^{N}$ with weights $\left\{{\stackrel{˜}{w}}_{t}^{\left(i\right)}{\right\}}_{i=1}^{N}$.

• Set $t←t+1$ and go to step 2.