Two Popular Bayesian Estimators: Particle and Kalman Filters
McGill COMP 765 Sept 14th, 2017
Two Popular Bayesian Estimators: Particle and Kalman Filters - - PowerPoint PPT Presentation
Two Popular Bayesian Estimators: Particle and Kalman Filters McGill COMP 765 Sept 14 th , 2017 z = observation u = action Recall: Bayes Filters x = state ( ) ( | , , , ) Bel x P x u z u z 1 1 t t t t
McGill COMP 765 Sept 14th, 2017
1 1 1
t t t t t t t
1 1 1 1 t t t t t
Bayes z = observation u = action x = state
1 1 t t t t
Markov
1 1 t t t t
Markov
1 1 1 1 1
t t t t t t t t
1 1 1 1 1 1 1
t t t t t t t t
Total prob. Markov
1 1 1 1 1 1
t t t t t t t t
1.
Algorithm Discrete_Bayes_filter( Bel(x),d ): 2. 0 3. If d is a perceptual data item z then 4. For all x do 5. 6. 7. For all x do 8. 9. Else if d is an action data item u then 10. For all x do 11. 12. Return Bel’(x)
) ( ) | ( ) ( ' x Bel x z P x Bel ) ( ' x Bel ) ( ' ) ( '
1
x Bel x Bel
'
) ' ( ) ' , | ( ) ( '
x
x Bel x u x P x Bel
t
1 1 1
t t t t t t t
Consider distributions to each p(x| zi)
10
Wanted: samples distributed according to p(x| z1, z2, z3)
We can draw samples from p(x|zl) by adding noise to the detection parameters.
samples from another distribution (g) For example, suppose we want to estimate the expected value of f given only samples from g.
samples from another distribution (g)
samples from another distribution (g)
Weights describe the mismatch between the two distributions, i.e. how to reweigh samples to
samples of g
) ,..., , ( ) ( ) | ( ) ,..., , | ( : f
distributi Target
2 1 2 1 n k k n
z z z p x p x z p z z z x p
) ( ) ( ) | ( ) | ( : g
distributi Sampling
l l l
z p x p x z p z x p ) ,..., , ( ) | ( ) ( ) | ( ) ,..., , | ( : w weights Importance
2 1 2 1 n l k k l l n
z z z p x z p z p z x p z z z x p g f
Weighted samples After resampling
Here are all of our p(x|zi) samples, now with w attached (not shown). If we re-draw from these samples, weighted by w, we get…
Recall: weighting to remove sample bias
Want posterior belief after update Sample from propagation, before update
This algorithm is known as a particle filter. Want posterior belief after update Sample from propagation, before update
Actual observation and control received
Particle propagation/prediction: noise needs to be added in order to make particles differentiate from each other. If propagation is deterministic then particles are going to collapse to a single particle after a few resampling steps.
Weight computation as measurement likelihood. For each particle we compute the probability of the actual observation given the state is at that particle.
Resampling step Note: particle deprivation heuristics are not shown here
Resampling: The particle locations now have a chance to adapt according to the weights. More likely particles persist, while unlikely choices are removed.
w2 w3 w1 wn Wn-1
w2 w3 w1 wn Wn-1
2.
Generate cdf 4. 5. Initialize threshold
Draw samples … 7. While ( ) Skip until next threshold reached 8. 9. Insert 10. Increment threshold
1 1
, ' w c S n i 2
i i i
w c c
1
1 ], , ] ~
1 1
i n U u n j 1
1 1
n u u
j j i j
c u
1
, ' ' n x S S
i
1 i i
Also called stochastic universal sampling
Start
Laser sensor Sonar sensor
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Linear dynamics with Gaussian noise Linear observations with Gaussian noise Initial belief is Gaussian
Without linearity there is no closed-form solution for the posterior belief in the Bayes’ Filter. Recall that if X is Gaussian then Y=AX+b is also Gaussian. This is not true in general if Y=h(X). Also, we will see later that applying Bayes’ rule to a Gaussian prior and a Gaussian measurement likelihood results in a Gaussian posterior.
This results in the belief remaining Gaussian after each propagation and update step. This means that we only have to worry about how the mean and the covariance of the belief evolve recursively with each prediction step and update step COOL!
This makes the recursive updates of the mean and covariance much simpler.
Assumptions guarantee that if the prior belief before the prediction step is Gaussian then the prior belief after the prediction step will be Gaussian and the posterior belief (after the update step) will be Gaussian.
So, under the Kalman Filter assumptions we get Belief after prediction step (to simplify notation) Notation: estimate at time t given history of observations and controls up to time t-1
So, under the Kalman Filter assumptions we get Two main questions: 1. How to get prediction mean and covariance from prior mean and covariance?
prediction mean and covariance? These questions were answered in the 1960s. The resulting algorithm was used in the Apollo missions to the moon, and in almost every system in which there is a noisy sensor involved COOL!
Suppose your measurement model is with Suppose your first noisy measurement is Suppose your belief after the prediction step is Q: What is the mean and covariance of ?
From Bayes’ Filter we get so
From Bayes’ Filter we get so
Prediction residual/error between actual observation and expected
You expected the measured mean to be 0, according to your prediction prior, but you actually observed 5. The smaller this prediction error is the better your estimate will be, or the better it will agree with the measurements.
From Bayes’ Filter we get so
Kalman Gain: specifies how much effect will the measurement have in the posterior, compared to the prediction prior. Which one do you trust more, your prior ,
From Bayes’ Filter we get so
The measurement is more confident (lower variance) than the prior, so the posterior mean is going to be closer to 5 than to 0.
From Bayes’ Filter we get so
No matter what happens, the variance of the posterior is going to be reduced. I.e. new measurement increases confidence no matter how noisy it is.
From Bayes’ Filter we get so
In fact you can write this as so and I.e. the posterior is more confident than both the prior and the measurement.
From Bayes’ Filter we get so In this example:
Another example:
Take-home message: new observations, no matter how noisy, always reduce uncertainty in the posterior. The mean of the posterior, on the other hand,
Suppose that the dynamics model is and you applied the command . Then
Recall: this notation means expected value with respect to conditional expectation, i.e Control is a constant with respect to the distribution Dynamics noise is zero mean, and independent of observations and controls
Suppose that the dynamics model is and you applied the command . Then
Recall: this notation means covariance with respect to conditional expectation, i.e
Suppose that the dynamics model is and you applied the command . Then
Recall: covariance neglects addition
Cov(X+b) = Cov(X)
Suppose that the dynamics model is and you applied the command . Then
Recall: Cov(X+Y)=Cov(X)+Cov(Y)-2Cov(X,Y) Recall: we denote Cov(X,X)=Cov(X) as a shorthand
Suppose that the dynamics model is and you applied the command . Then
We assumed dynamics noise is independent
We assumed noise variables are independent of state. So this covariance is zero.
Suppose that the dynamics model is and you applied the command . Then
Suppose that the dynamics model is and you applied the command . Then
Suppose that the dynamics model is and you applied the command . Then
Take home message: uncertainty increases after the prediction step, because we are speculating about the future.
1.
Algorithm Kalman_filter( mt-1, St-1, ut, zt): 2. Prediction: 3. 4. 5. Correction: 6. 7. 8. 9. Return mt, St
t t t t t
u B A
1
m m
t T t t t t
R A A S S
1 1
) (
S S
t T t t t T t t t
Q C C C K ) (
t t t t t t
C z K m m m
t t t t
C K I S S ) (
S S
t T t t t t t t t t t t
R A A u B A x bel
1 1
) ( m m
2 , 2 2 2 1
) (
t act t t t t t t t t t
a u b a x bel m m
Prediction
1
) ( , ) ( ) ( ) (
S S S S
t T t t t T t t t t t t t t t t t t t t
Q C C C K C K I C z K x bel m m m
2 , 2 2 2 2
, ) 1 ( ) ( ) (
t
t t t t t t t t t t t t
K K z K x bel m m m
Correction
1
) ( , ) ( ) ( ) (
S S S S
t T t t t T t t t t t t t t t t t t t t
Q C C C K C K I C z K x bel m m m
2 , 2 2 2 2
, ) 1 ( ) ( ) (
t
t t t t t t t t t t t t
K K z K x bel m m m
S S
t T t t t t t t t t t t
R A A u B A x bel
1 1
) ( m m
2 , 2 2 2 1
) (
t act t t t t t t t t t
a u b a x bel m m
Correction Prediction