Particle filter

Nonparametric Filters
The Particle Filter
Particle Filter
• Particle filter is a kind of random algorithm.
Monte Carlo Method: Random sampling without the
exact knowledge
Monte Carlo (MC) Method
• A broad class of computational algorithms
that rely on repeated random sampling to
obtain numerical results.
• When it is difficult or impossible to use other
approaches.
• Mainly used in three problems:
1. Optimization,
2. Numerical integration,
3. Approximate a probability distribution.
Particle Filter
• Approximate the posterior by Monte Carlo
sampling.
• It is known as:
– Sequential Monte Carlo method (SMC)
– Bootstrap filtering
– The condensation algorithm
– Particle filter
– Survival of the fittest
Particle Filters (PF)



PF represents belief by random samples
It can estimate non-Gaussian, nonlinear processes
The key is to approximate bel(t) by a set of random samples drawn
from this posterior.
Original PDF
Sigma point approximation
UKF
Monte Carlo approximation
PF
The likelihood for xt to be
included in Xt is proportional
to the posterior bel(xt)
The denser the sub-region, the
more likely the true state falls
into this region.
Represent PDF by the density
of particles
The general problem we are
considering
System model:
xk  f k ( xk 1 , vk 1 )
zk  hk ( xk , nk )
We want to calculate:
p ( xk | z1:k )
based on
p ( xk 1 | z1:k 1 )
and
zk
Prediction:
p ( xk | z1:k 1 )   p ( xk | xk 1 , z1:k 1 ) p ( xk 1 | z1:k 1 )dxk 1
  p ( xk | xk 1 ) p ( xk 1 | z1:k 1 )dxk 1
The general problem we are
considering
We want to calculate:
p ( xk | z1:k )
based on
p ( xk 1 | z1:k 1 )
and
zk
Update:
p ( xk | z1:k )  ?
Recall Bayes Filter:
P ( y | x, z ) P ( x | z )
P( x | y, z ) 
P( y | z )
p ( zk | xk , z1:k 1 ) p ( xk | z1:k 1 )
p ( xk | z1:k )  p ( xk | zk , z1:k 1 ) 
p ( zk | z1:k 1 )
p ( zk | xk ) p ( xk | z1:k 1 )

  p ( zk | xk ) p ( xk | z1:k 1 )
p ( zk | z1:k 1 )
The summary of general problem
Input:
p ( xk 1 | z1:k 1 )
and
zk
Prediction:
p ( xk | z1:k 1 ) 
 p( x
k
| xk 1 ) p ( xk 1 | z1:k 1 )dxk 1
Update:
p ( xk | z1:k )   p( zk | xk ) p( xk | z1:k 1 )
Particle Filter
The distribution of
p( xk | z1:k )
A set of particles
x
i
0:k
Ns
,w 
i Ns
i 1
p ( x0:k | z1:k )   wki   x0:k  x0:i k 
i 1
i
x
 0:k , i  0,
, Ns
is an arbitrary distribution
is used to characterize
p( xk | z1:k )
Particle representation
of the posterior
is a set of supporting points, particles
w , i  0, , N  are the associated weights of the particles.
x   x , j  0, , k  is the set of all states up to time k
i
k
0:k
s
j
Ns
i
w
 k 1
i 1
How the
samples
are drawn?
Ns is the number of particles, e.g., 1000.
How the
weights are
assigned?
Importance Sampling
• The distribution p(x) is hard to sample.
• p( x)   ( x) , which can be evaluated by  ( x)
• Let xi ~ q( x), i  1, , N s be samples that are
easily generated by a proposal distribution q( x)
• q( x) is called importance density.
• A weighted approximation to p(x) is given by:
Ns
 ( xi )
i 1
q( xi )
p ( x)   wi   x  x i , wi 
q( x)
Importance Sampling
p( x)
q( x)
Ns
 ( xi )
i 1
q( xi )
p( x)   wi   x  xi , wi 
Sampling in PF
Ns
p( x0:k | z1:k )   wki   x0:k  x0:i k 
i 1
Samples are drawn from
q ( x0:k | z1:k )
i
p
(
x
i
0:k | z1:k )
wk 
q ( x0:i k | z1:k )
What
should it
be?
How to
calculate it
sequentially
Derivation of Sequential PF
q( x0:k | z1:k )  q( xk | x0:k 1 , z1:k )q( x0:k 1 | z1:k 1 )
p ( x0:k | z1:k )   p ( zk | x0:k , z1:k 1 ) p ( x0:k | z1:k 1 )
  p ( zk | xk ) p ( x0:k | z1:k 1 )
Bayes
Markov
  p ( zk | xk ) p ( xk | x0:k 1 , z1:k 1 ) p ( x0:k 1 | z1:k 1 )
  p ( zk | xk ) p ( xk | xk 1 ) p ( x0:k 1 | z1:k 1 )
Markov
Derivation of Sequential PF
i
p
(
x
i
0:k | z1:k )
wk 
q( x0:i k | z1:k )
i
i
i
i
p
(
z
|
x
)
p
(
x
|
x
)
p
(
x
i
k
k
k
k 1
0:k 1 | z1:k 1 )
wk 
q ( xki | x0:i k 1 , z1:k )q ( x0:i k 1 | z1:k 1 )
Sequenti
ally
calculate
d
 wki 1
p ( zk | xki ) p ( xki | xki 1 )
q ( xki | x0:i k 1 , z1:k )
 wki 1
p ( zk | xki ) p ( xki | xki 1 ) q( xi | xi , z )  q( xi | xi , z )
if k 0:k 1 1:k
k
k 1 1:k
i
i
q ( xk | xk 1 , z1:k )
 wki 1 p ( zk | xki ) if q ( xki | xki 1 , z1:k )  p( xki | xki 1 )
Selection
of q()
Basic PF Algorithm
Input:
p ( xki 1 | z1:k 1 )
and
zk
Sampling:
Draw samples from
p ( xki | xki 1 )
Assign weights by
wki  wki 1 p ( zk | xki )
Update:
Ns
p ( xk | z1:k )   wki   xk  xki 
i 1
Problems of basic PF
1. Degeneracy problem
– Weights of all but one particles are near zero after
several iterations.
– The variance of weights increase over time, which
is impossible to avoid [Doucet1998]
Solve Degeneracy problem
• Measurement of Degeneracy
N eff
Ns

1  Var ( wk*i )
Nˆ eff 
1
Ns
w 
i 1
• Small
wk*i  p ( xki | z1:k ) / q ( xki | xki 1 , zk )
Nˆ eff
i 2
k
Index of
degeneracy
indicates severe degeneracy.
1. A good choice of importance density
2. Use of resampling
(1) Good choice of importance density
• The optimal importance density [Doucet1998]
q  xk | xki 1 , zk 
opt
 p  xk | xki 1 , zk 

wki  wki 1
i
k 1
=w
p  zk | xk , xki 1  p  xk | xki 1 
p  zk | xki 1 
p ( zk | xki ) p ( xki | xki 1 )
q ( xki | xki 1 , z1:k )
i
k -1
p ( zk | x )
=wki 1  p ( zk | x) p ( x | xki -1 )dx
Difficult to
calculate
Can be used when
the observation is
linear
A simple choice is:
q  xk | xki 1 , zk   p  xk | xki 1 
(2) Resampling
• Generating a new particle set by resampling
Ns times, and reset the weights to 1/Ns .
x , w 
i
k
i Ns
k i 1
P ( xki*  xkj )  wkj
Ns
 i* 1 
 xk , 
N s i 1

• Resampling algorithms
1. Systematic resampling [Kitagawa1996]
2. Stratified sampling, residue sampling [Liu 1998]
3. Chopthin [Gandy2015]
Systematic resampling
CDF of current
weights
The particle with larger
weight will be chosen
many times
Generate from existing
particles
Generic Particle Filter Algorithm
Input:
p ( xki 1 | z1:k 1 )
and
zk
Sampling:
Draw samples from
p ( xki | xki 1 )
Assign weights by
wki  wki 1 p ( zk | xki )
Update:
Ns
p ( xk | z1:k )   wki   xk  xki 
i 1
Check degeneracy
If Nˆ  N
eff
Resampling
T
p(xt-1 )
Generate particles
ct-1 µ p(xt-1 )
xti ~ p( xt | ut , xti 1 )
State transition
Weights are sampled based on
observations.
wti  p( zt | xti )
Resampling according to
weights to approximate the
posterior.
http://hawaii.aist-nara.ac.jp/~tom/research/track-j.htm
Typical PF algorithms (1): SIR
1. SIR particle filter
Typical PF algorithms (2): RPF
• Regularized Particle Filter
– Address the sample impoverishment problem.
– RPF samples from a continuous approximation
Ns
p ( x0:k | z1:k )   w K h  xk  x
i 1
Kh 
1 x
k 
nx
h
h
i
k
i
k

PF examples: Stochastic Volatility
PF Examples
PF Examples
Ground truth
EKF
EKF tracks
poorly
SIR
Ground truth
SIR
SIR is much
better
RPF
Ground truth
RPF
RPF is much
better
MLSE
Particle Filter Implementation
Related readings
• Chopchin