Top Banner
Particle Particle Filters Filters
51

Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Dec 21, 2015

Download

Documents

Alan Ross
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Particle Particle FiltersFilters

Page 2: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Importance Importance SamplingSampling

Page 3: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Importance SamplingImportance Sampling• Unfortunately it is often not possible to sample directly from the posterior

distribution, but we can use importance sampling.

• Let p(x) be a pdf from which it is difficult to draw samples.

• Let xi ~ q(x), i=1, …, N, be samples that are easily generated from a proposal pdf q, which is called an importance density.

• Then approximation to the density p is given by

)(

)(i

ii

xq

xpw

)()(1

in

i

i xxwxp

•where

Page 4: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Bayesian Importance SamplingBayesian Importance Sampling

• By drawing samples from a known easy to sample proposal distribution we obtain:

N

i

ikk

ikkk xxwDxp

1:0:0:0 )()|(

)|( :0 kk Dxq

ikx :0

)|(

)|(

:0

:0

ki

k

ki

kik Dxq

Dxpw

•where

•are normalized weights.

Page 5: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Sensor Information: Importance Sampling

Page 6: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Sequential Importance Sampling (I)Sequential Importance Sampling (I)• Factorizing the proposal distribution:

• and remembering that the state evolution is modeled as a Markov process

• we obtain a recursive estimate of the importance weights:

• Factorizing is obtained by recursively applying

k

jjjjkk DxxqxqDxq

11:00:0 ),|()()|(

),|(

)|()|(

1:0

11

kkk

kkkkkk Dxxq

xxpxypww

)|(),|()|( 11:01:0:0 kkkkkkk DxqDxxqDxq

Page 7: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

•Sequential Importance Sampling (SIS) Particle Filter

•SIS Particle Filter Algorithm

],},[{]},[{ 1111 kNi

ik

ik

Ni

ik

ik zwxSISwx

•for i=1:N

•Draw a particle

•Assign a weight

•end

),|(~ 1 kik

ik

ik zxxqx

),|(

)|()|(

1:0

11

ki

kik

ik

ik

ikki

kik Dxxq

xxpxzpww

•(k is index over time and i is the particle index)

Page 8: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Rejection Rejection SamplingSampling

Page 9: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Let us assume that f(x)<1 for all x

Sample x from a uniform distribution

Sample c from [0,1]

if f(x) > c keep the sampleotherwise reject the sample

Rejection SamplingRejection Sampling

•c

•x

•f(x)

•c’

•x’

•f(x’)

•OK

Page 10: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Importance Sampling with Importance Sampling with Resampling:Resampling:

Landmark Detection ExampleLandmark Detection Example

Page 11: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Distributions

Page 12: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Distributions

•Wanted: samples distributed according to p(x| z1, z2, z3)

Page 13: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

This is Easy!•We can draw samples from p(x|zl) by adding noise to the detection parameters.

Page 14: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Importance sampling with Resampling

•After After ResamplingResampling

Page 15: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Particle Particle Filter Filter

AlgorithmAlgorithm

Page 16: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

weight =

target distribution / proposal distribution

Page 17: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

•draw xit1 from Bel(xt1)

•draw xit from p(xt | xi

t1,ut1)

•Importance factor for xit:

)|(

)(),|(

)(),|()|(

ondistributi proposal

ondistributitarget

111

111

tt

tttt

tttttt

it

xzp

xBeluxxp

xBeluxxpxzp

w

1111 )(),|()|()( tttttttt dxxBeluxxpxzpxBel

Particle Filter Algorithm

Page 18: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

1. Algorithm particle_filter( St-1, ut-1 zt):

2.

3. For Generate new samples

4. Sample index j(i) from the discrete distribution given by wt-

1

5. Sample from using and

6. Compute importance weight

7. Update normalization factor

8. Insert

9. For

10. Normalize weights

Particle Filter Algorithm

0, tS

ni 1

},{ it

ittt wxSS

itw

itx ),|( 11 ttt uxxp )(

1ij

tx 1tu

)|( itt

it xzpw

ni 1/i

tit ww

Page 19: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Particle Filter Algorithm

Page 20: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Particle Filter for LocalizationParticle Filter for Localization

Page 21: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Particle Filter in Particle Filter in Matlab Matlab

Page 22: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

•Matlab code: truex is a vector of 100 positions to be tracked.Matlab code: truex is a vector of 100 positions to be tracked.

Page 23: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Application: Particle Filter for Localization Application: Particle Filter for Localization (Known Map)(Known Map)

Page 24: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

ResamplingResampling

Page 25: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

ResamplingResampling

Page 26: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

ResamplingResampling

Page 27: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

1. Algorithm systematic_resampling(S,n):

2.

3. For Generate cdf4. 5. Initialize threshold

6. For Draw samples …7. While ( ) Skip until next threshold reached8. 9. Insert10. Increment threshold

11. Return S’

Resampling Algorithm

11,' wcS

ni 2i

ii wcc 1

1],,0]~ 11 inUu

nj 1

11

nuu jj

ij cu

1,'' nxSS i

1ii

•Also called stochastic universal sampling

Page 28: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Low Variance Resampling

Page 29: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

SIS SIS weightsweights

Page 30: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Derivation of SIS weights (I)Derivation of SIS weights (I)• The main idea is Factorizing :

k

jjjk xxpxpxp

110:0 )|()()( •and

k

jjjkk xypxDp

1:0 )|()|(

)|(

)|(

:0

:0

ki

k

ki

kik Dxq

Dxpw

)|(),|()|( 11:01:0:0 kkkkkkk DxqDxxqDxq

•Our goal is to expand p and q in time t

Page 31: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Derivation of SIS weights (II)

)()|(

)()|()|(),|(

)(

)()|()|(

11

1:01:0:01:01:0:0:0

kkk

kkkkkkkk

k

kkkkk DpDzp

xpxxpxDpxDzp

Dp

xpxDpDxp

)|(

)|()|(),|(

1

11:01:0:01

kk

kkkkkkk

Dzp

DxpxxpxDzp

)()|(

)()|()|(),|(

11

1:01:011:0:01

kkk

kkkkkkkk

DpDzp

xpxDpxxpxDzp

)|()|(),|( 11:01:0:01 kkkkkkk DxpxxpxDzp

Page 32: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

)|(

)|(

),|(

)|(),|(

)|(

)|(

11:0

11:0

1:0

1:0:01

:0

:0

k

ik

ki

k

ki

kik

ik

ik

ikkk

ki

k

ki

kik Dxq

Dxp

Dxxq

xxpxDzp

Dxq

Dxpw

•Derivation of SIS weights (II)

),|(

)|(),|(

1:0

1:0:011

ki

kik

ik

ik

ikkki

k Dxxq

xxpxDzpw

),|(

)|()|(

1

11

kik

ik

ik

ik

ikki

kik zxxq

xxpxzpww

•and under Markov assumptions

Page 33: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

SIS Particle Filter Foundation• At each time step k• Random samples are drawn from the proposal distribution for i=1, …, N

• They represent posterior distribution using a set of samples or particles

• Since the weights are given by

• and q factorizes as

N

i

ikk

ikkk xxwDxp

1

)()|(

ikx

),|( 1:0 kkk Dxxq

)|(

)|(

:0

:0

ki

k

ki

kik Dxq

Dxpw

k

jjjjkk DxxqxqDxq

11:00:0 ),|()()|(

Page 34: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Sequential Importance Sampling (II)

• Choice of the proposal distribution:

• Choose proposal function to minimize variance of (Doucet et al. 1999):

• Although common choice is the prior distribution:

We obtain then

),|( 1:0 kkk Dxxq

kw

),|(),|( 1:01:0 kkkkkk DxxpDxxq

)|(),|( 11:0 kkkkk xxpDxxq

)|(),|(

)|()|(1

1:0

11

ikk

ik

ki

kik

ik

ik

ikki

kik xzpw

Dxxq

xxpxzpww

Page 35: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

• Illustration of SIS:

• Degeneracy problems:– variance of importance ratios

increases stochastically over time (Kong et al. 1994; Doucet et al. 1999).

– In most cases then after a few iterations, all but one particle will have negligible weight

Sequential Importance Sampling (III)

w

Time 19

w

Time 10

w

Time 1

)|(/)|( :0:0 kkkk DxqDxp

Page 36: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Sequential Importance Sampling (IV)

• Illustration of degeneracy:

w

Time 19

w

Time 10

w

Time 1

Page 37: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

SIS - why variance increase• Suppose we want to sample from the posterior

– choose a proposal density to be very close to the posterior density

• Then

• and

• So we expect the variance to be close to 0 to obtain reasonable estimates– thus a variance increase has a harmful effect on accuracy

1)|(

)|(

:0

:0

kk

kkq Dxq

DxpE

01)|(

)|(

)|(

)|(var

2

:0

:0

:0

:0

kk

kkq

kk

kkq Dxq

DxpE

Dxq

Dxp

Page 38: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.
Page 39: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

SamplingSampling--

Importance Importance ResamplingResampling

Page 40: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Sampling-Importance ResamplingSampling-Importance Resampling• SIS suffers from degeneracy problems so we don’t

want to do that!• Introduce a selection (resampling) step to eliminate

samples with low importance ratios and multiply samples with high importance ratios.

• Resampling maps the weighted random measure on to the equally weighted random measure – by sampling uniformly with replacement from

with probabilities

• Scheme generates children such that and satisfies:

)}(~,{ :0:0i

kki

k xwx

} { 1-:0 Nx jk

},,1;{ :0 Nixik },,1;~{ Niwi

k

NNN

ii

1

iN

iki wNNE ~)(

)~1(~)var( ik

iki wwNN

Page 41: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Basic SIR Particle Filter - Schematic•Initialisation

•Importance•sampling step

•Resampling•step

0k

1 kk

)}(~,{ :0:0i

kki

k xwx

},{ 1:0

Nxik

•measurement

ky

•Extract estimate, kx :0ˆ

Page 42: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Basic SIR Particle Filter algorithm (I)• Initialisation

– – For sample – and set

0k

Ni ,,1 )(~ 00 xpxi

1k

Importance Sampling step

– For sample

– For compute the importance

weights wik

– Normalise the importance weights,

N

j

jk

ik

ik www

1

/~

Ni ,,1 )|(~~1

ikk

ik xxqx

),(~1:0:0

ik

ik

ik xxx •and set

Ni ,,1

Page 43: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Basic SIR Particle Filter algorithm (II)

• Resampling step– Resample with replacement particles:

– from the set:

– according to the normalised importance weights,

• Set– proceed to the Importance Sampling step, as the next

measurement arrives.

N

),,1;( :0 Nixik

),,1;~( :0 Nix ik

ikw~

1 kk

Page 44: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Resampling

M

m

mk M

x1

)(1

1,

•x

M

mm

km

k wx 1)()( ,

M

m

m

kM

x1

)(~ 1,

M

m

mk M

x1

)(1

1,

M

mm

km

k wx 1)(1

)(1 ,

M

m

m

kM

x1

)(

1

~ 1,

M

m

mk M

x1

)(2

1,

Page 45: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

•Generic SIR Particle Filter algorithm

•M. S. Arulampalam, S. Maskell, N. Gordon, and T. Clapp, “A tutorial on particle filters …,” IEEE Trans. on Signal Processing,

50( 2), 2002.

Page 46: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Improvements to SIR (I)Improvements to SIR (I)• Variety of resampling schemes with varying

performance in terms of the variance of the particles :– Residual sampling (Liu & Chen, 1998).– Systematic sampling (Carpenter et al., 1999).– Mixture of SIS and SIR, only resample when necessary (Liu &

Chen, 1995; Doucet et al., 1999).

• Degeneracy may still be a problem:– During resampling a sample with high importance weight may

be duplicated many times.– Samples may eventually collapse to a single point.

)var( iN

Page 47: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Improvements to SIR (II)

• To alleviate numerical degeneracy problems, sample smoothing methods may be adopted.– Roughening (Gordon et al., 1993).

• Adds an independent jitter to the resampled particles

– Prior boosting (Gordon et al., 1993).• Increase the number of samples from the proposal

distribution to M>N, • but in the resampling stage only draw N particles.

Page 48: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Improvements to SIR (III)

• Local Monte Carlo methods for alleviating degeneracy:– Local linearisation - using an EKF (Doucet, 1999; Pitt & Shephard, 1999) or

UKF (Doucet et al, 2000) to estimate the importance distribution.– Rejection methods (Müller, 1991; Doucet, 1999; Pitt & Shephard, 1999).– Auxiliary particle filters (Pitt & Shephard, 1999)– Kernel smoothing (Gordon, 1994; Hürzeler & Künsch, 1998; Liu & West, 2000; Musso et

al., 2000).– MCMC methods (Müller, 1992; Gordon & Whitby, 1995; Berzuini et al., 1997; Gilks &

Berzuini, 1998; Andrieu et al., 1999).

Page 49: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Improvements to SIR (IV)

• Illustration of SIR with sample smoothing:

w

Time 19

w

Time 10

w

Time 1

Page 50: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Ingredients for SMCIngredients for SMC• Importance sampling function

– Gordon et al – Optimal – UKF pdf from UKF at

• Redistribution scheme– Gordon et al SIR– Liu & Chen Residual– Carpenter et al Systematic– Liu & Chen, Doucet et al Resample when necessary

• Careful initialisation procedure (for efficiency)

)|( 1ikk xxp

),|( 1:0 ki

kk Dxxp ikx 1

Page 51: Particle Filters Importance Sampling Unfortunately it is often not possible to sample directly from the posterior distribution, but we can use importance.

Sources• Longin Jan Latecki • Keith Copsey • Paul E. Rybski• Cyrill Stachniss • Sebastian Thrun • Alex Teichman• Michael Pfeiffer• J. Hightower• L. Liao• D. Schulz• G. Borriello• Honggang Zhang• Wolfram Burgard• Dieter Fox

•51

• Giorgio Grisetti• Maren Bennewitz• Christian Plagemann • Dirk Haehnel• Mike Montemerlo• Nick Roy• Kai Arras• Patrick Pfaff• Miodrag Bolic• Haris Baltzakis