# Particle filter

Particle filters or Sequential Monte Carlo (SMC) methods are a set of on-line posterior density estimation algorithms that estimate the posterior density of the state-space by directly implementing the Bayesian recursion equations. SMC methods use a grid-based approach, and use a set of particles to represent the posterior density. These filtering methods make no restrictive assumption about the dynamics of the state-space or the density function. SMC methods provide a well-established methodology for generating samples from the required distribution without requiring assumptions about the state-space model or the state distributions. The state-space model can be non-linear and the initial state and noise distributions can take any form required. However, these methods do not perform well when applied to high-dimensional systems. SMC methods implement the Bayesian recursion equations directly by using an ensemble based approach. The samples from the distribution are represented by a set of particles; each particle has a weight assigned to it that represents the probability of that particle being sampled from the probability density function.

Weight disparity leading to weight collapse is a common issue encountered in these filtering algorithms; however it can be mitigated by including a resampling step before the weights become too uneven. In the resampling step, the particles with negligible weights are replaced by new particles in the proximity of the particles with higher weights.

## History

The first traces of particle filters date back to the 50's; the 'Poor Man's Monte Carlo', that was proposed by Hammersley et al., in 1954, contained hints of the SMC methods used today. Later in the 70's, similar attempts were made in the control community. However it was in 1993, that Gordon et al., published their seminal work 'A novel Approach to nonlinear/non-Gaussian Bayesian State estimation', that provided the first true implementation of the SMC methods used today. The authors named their algorithm 'the bootstrap filter', and demonstrated that compared to other filtering methods, their algorithm does not require any assumption about that state-space or the noise of the system.

## Objective

The objective of a particle filter is to estimate the posterior density of the state variables given the observation variables. The particle filter is designed for a hidden Markov Model, where the system consists of hidden and observable variables. The observable variables (observation process) are related to the hidden variables (state-process) by some functional form that is known. Similarly the dynamical system describing the evolution of the state variables is also known probabilistically.

A generic particle filter estimates the posterior distribution of the hidden states using the observation measurement process. Consider a state-space shown in the diagram (Figure 2).

Figure 2. The State-Space (The Hidden states given by the vector x, and the observation states given by the vector y)

The objective of the particle filter is to estimate the values of the hidden states x, given the values of the observation process y.

The particle filter aims to estimate the sequence of hidden parameters, xk for k = 0,1,2,3,…, based only on the observed data yk for k = 0,1,2,3,…. All Bayesian estimates of xk follow from the posterior distribution p(xk | y0,y1,…,yk). In contrast, the MCMC or importance sampling approach would model the full posterior p(x0,x1,…,xk | y0,y1,…,yk).

## Model

Particle methods assume $x_k$ and the observations $y_k$ can be modeled in this form:

• $x_0, x_1, \ldots$ is a first order Markov process that evolves according to the distribution $p_{x_k|x_{k-1}}$:
$x_k|x_{k-1} \sim p_{x_k|x_{k-1}}(x|x_{k-1})$

and with an initial distribution $p(x_0)$.

• The observations $y_0, y_1, \ldots$ are conditionally independent provided that $x_0, x_1, \ldots$ are known
In other words, each $y_k$ only depends on $x_k$. This conditional distribution for $y_k$ is written as
$y_k|x_k \sim p_{y|x}(y|x_k)$

An example system with these properties is:

$x_k = g(x_{k-1}) + w_k \,$
$y_k = h(x_k) + v_k \,$

where both $w_k$ and $v_k$ are mutually independent and identically distributed sequences with known probability density functions and $g(\cdot)$ and $h(\cdot)$ are known functions. These two equations can be viewed as state space equations and look similar to the state space equations for the Kalman filter. If the functions $g(\cdot)$ and $h(\cdot)$ are linear, and if both $w_k$ and $v_k$ are Gaussian, the Kalman filter finds the exact Bayesian filtering distribution. If not, Kalman filter based methods are a first-order approximation (EKF) or a second-order approximation (UKF in general, but if probability distribution is Gaussian a third-order approximation is possible). Particle filters are also an approximation, but with enough particles they can be much more accurate.

## Monte Carlo approximation

Particle methods, like all sampling-based approaches (e.g., MCMC), generate a set of samples that approximate the filtering distribution $p(x_k|y_0,\dots,y_k)$. For example, we may have $N$ samples from the approximate posterior distribution of $x_k$, where the samples are labeled with superscripts as $x_k^{(1)}, x_k^{(2)}, \ldots, x_k^{(N)}$. Then, expectations with respect to the filtering distribution are approximated by

$\int f(x_k)p(x_k|y_0,\dots,y_k) \, dx_k\approx\sum_{L=1}^Nf\left(x_k^{(L)}\right)\frac1N$

and $f(\cdot)$, in the usual way for Monte Carlo, can give all the moments etc. of the distribution up to some degree of approximation.

## Sequential importance resampling (SIR)

Sequential importance resampling (SIR), the original particle filtering algorithm (Gordon et al. 1993), is a very commonly used particle filtering algorithm, which approximates the filtering distribution $p(x_k|y_0,\ldots,y_k)$ by a weighted set of P particles

$\{(w^{(L)}_k,x^{(L)}_k)~:~L\in\{1,\ldots,P\}\}.$

The importance weights $w^{(L)}_k$ are approximations to the relative posterior probabilities (or densities) of the particles such that $\sum_{L=1}^P w^{(L)}_k = 1$.

SIR is a sequential (i.e., recursive) version of importance sampling. As in importance sampling, the expectation of a function $f(\cdot)$ can be approximated as a weighted average

$\int f(x_k) p(x_k|y_0,\dots,y_k) dx_k \approx \sum_{L=1}^P w_k^{(L)} f(x_k^{(L)}).$

For a finite set of particles, the algorithm performance is dependent on the choice of the proposal distribution

$\pi(x_k|x_{0:k-1},y_{0:k})\,$.

The optimal proposal distribution is given as the target distribution

$\pi(x_k|x_{0:k-1},y_{0:k}) = p(x_k|x_{k-1},y_{k}). \,$

However, the transition prior probability distribution is often used as importance function, since it is easier to draw particles (or samples) and perform subsequent importance weight calculations:

$\pi(x_k|x_{0:k-1},y_{0:k}) = p(x_k|x_{k-1}). \,$

Sequential Importance Resampling (SIR) filters with transition prior probability distribution as importance function are commonly known as bootstrap filter and condensation algorithm.

Resampling is used to avoid the problem of degeneracy of the algorithm, that is, avoiding the situation that all but one of the importance weights are close to zero. The performance of the algorithm can be also affected by proper choice of resampling method. The stratified sampling proposed by Kitagawa (1996) is optimal in terms of variance.

A single step of sequential importance resampling is as follows:

1) For $L=1,\ldots,P$ draw samples from the proposal distribution
$x^{(L)}_k \sim \pi(x_k|x^{(L)}_{0:k-1},y_{0:k})$
2) For $L=1,\ldots,P$ update the importance weights up to a normalizing constant:
$\hat{w}^{(L)}_k = w^{(L)}_{k-1} \frac{p(y_k|x^{(L)}_k) p(x^{(L)}_k|x^{(L)}_{k-1})} {\pi(x_k^{(L)}|x^{(L)}_{0:k-1},y_{0:k})}.$
Note that when we use the transition prior probability distribution as the importance function, $\pi(x_k^{(L)}|x^{(L)}_{0:k-1},y_{0:k}) = p(x^{(L)}_k|x^{(L)}_{k-1})$, this simplifies to the following  :
$\hat{w}^{(L)}_k = w^{(L)}_{k-1} p(y_k|x^{(L)}_k),$
3) For $L=1,\ldots,P$ compute the normalized importance weights:
$w^{(L)}_k = \frac{\hat{w}^{(L)}_k}{\sum_{J=1}^P \hat{w}^{(J)}_k}$
4) Compute an estimate of the effective number of particles as
$\hat{N}_\mathit{eff} = \frac{1}{\sum_{L=1}^P\left(w^{(L)}_k\right)^2}$
5) If the effective number of particles is less than a given threshold $\hat{N}_\mathit{eff} < N_{thr}$, then perform resampling:
a) Draw $P$ particles from the current particle set with probabilities proportional to their weights. Replace the current particle set with this new one.
b) For $L=1,\ldots,P$ set $w^{(L)}_k = 1/P.$

The term Sampling Importance Resampling is also sometimes used when referring to SIR filters.

## Sequential importance sampling (SIS)

• Is the same as sequential importance resampling, but without the resampling stage.

## "direct version" algorithm

The "direct version" algorithm[citation needed] is rather simple (compared to other particle filtering algorithms) and it uses composition and rejection. To generate a single sample $x$ at $k$ from $p_{x_k|y_{1:k}}(x|y_{1:k})$:

1) Set n=0 (This will count the number of particles generated so far)
2) Uniformly choose an index L from the range $\{1,..., P\}$
3) Generate a test $\hat{x}$ from the distribution $p_{x_k|x_{k-1}}(x|x_{k-1|k-1}^{(L)})$
4) Generate the probability of $\hat{y}$ using $\hat{x}$ from $p_{y|x}(y_k|\hat{x})$ where $y_k$ is the measured value
5) Generate another uniform u from $[0, m_k]$ where $m_k = \sup_x p_{y|x}(y_k|x)$
6) Compare u and $p\left(\hat{y}\right)$
6a) If u is larger then repeat from step 2
6b) If u is smaller then save $\hat{x}$ as $x_{k|k}^{(p)}$ and increment n
7) If n == P then quit

The goal is to generate P "particles" at $k$ using only the particles from $k-1$. This requires that a Markov equation can be written (and computed) to generate a $x_k$ based only upon $x_{k-1}$. This algorithm uses composition of the P particles from $k-1$ to generate a particle at $k$ and repeats (steps 2–6) until P particles are generated at $k$.

This can be more easily visualized if $x$ is viewed as a two-dimensional array. One dimension is $k$ and the other dimensions is the particle number. For example, $x(k,L)$ would be the Lth particle at $k$ and can also be written $x_k^{(L)}$ (as done above in the algorithm). Step 3 generates a potential $x_k$ based on a randomly chosen particle ($x_{k-1}^{(L)}$) at time $k-1$ and rejects or accepts it in step 6. In other words, the $x_k$ values are generated using the previously generated $x_{k-1}$.

## References

1. ^ Pitt, M.K.; Shephard, N. (1999). "Filtering Via Simulation: Auxiliary Particle Filters". Journal of the American Statistical Association (American Statistical Association) 94 (446): 590–591. doi:10.2307/2670179. JSTOR 2670179. Retrieved 2008-05-06.
2. ^ Liu, J.; Wang, W.; Ma, F. (2011). "A Regularized Auxiliary Particle Filtering Approach for System State Estimation and Battery Life Prediction". Smart Materials and Structures 20 (7): 1–9. doi:10.1088/0964-1726/20/7/075021.
3. ^ Canton-Ferrer, C.; Casas, J.R.; Pardàs, M. (2011). "Human Motion Capture Using Scalable Body Models". Computer Vision and Image Understanding (Elsevier) 115 (10): 1363–1374. doi:10.1016/j.cviu.2011.06.001.
4. ^ Doucet, A.; De Freitas, N. and Murphy, K. and Russell, S. (2000). "Rao–Blackwellised particle filtering for dynamic Bayesian networks". Proceedings of the Sixteenth conference on Uncertainty in artificial intelligence. pp. 176–183. CiteSeerX: 10.1.1.137.5199.
5. ^ Blanco, J.L.; Gonzalez, J. and Fernandez-Madrigal, J.A. (2008). "An Optimal Filtering Algorithm for Non-Parametric Observation Models in Robot Localization". IEEE International Conference on Robotics and Automation (ICRA'08). pp. 461–466. CiteSeerX: 10.1.1.190.7092.
6. ^ Blanco, J.L.; Gonzalez, J. and Fernandez-Madrigal, J.A. (2010). "Optimal Filtering for Non-Parametric Observation Models: Applications to Localization and SLAM". The International Journal of Robotics Research (IJRR) 29 (14): 1726–1742. doi:10.1177/0278364910364165.

## Bibliography

• Cappe, O.; Moulines, E.; Ryden, T. (2005). Inference in Hidden Markov Models. Springer.
• Liu, J. (2001). Monte Carlo strategies in Scientific Computing. Springer.
• Ristic, B.; Arulampalam, S.; Gordon, N. (2004). Beyond the Kalman Filter: Particle Filters for Tracking Applications. Artech House.
• Cappe, O.; Godsill, S.; Moulines, E.; (2007). "An overview of existing methods and recent advances in sequential Monte Carlo". Proceedings of IEEE 95 (5): 899. doi:10.1109/JPROC.2007.893250.
• Kitagawa, G. (1996). "Monte carlo filter and smoother for non-Gaussian nonlinear state space models". Journal of Computational and Graphical Statistics 5 (1): 1–25. doi:10.2307/1390750. JSTOR 1390750.
• Kotecha, J.H.; Djuric, P.; (2003). "Gaussian Particle filtering". IEEE Transactions Signal Processing 51 (10).
• Chen, Z. (2003). "Bayesian Filtering: From Kalman Filters to Particle Filters, and Beyond". CiteSeerX: 10.1.1.107.7415.
• Vaswani, N.; Rathi, Y. Yezzi, A., Tannenbaum, A. (2007). "Tracking deforming objects using particle filtering for geometric active contours". IEEE Trans. on Pattern Analysis and Machine Intelligence 29 (8): 1470=1475. doi:10.1109/tpami.2007.1081.