Cours_3
Cours_3
Cours_3
Samy Labsir
Webpage
1/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Introduction
Context
▶ In a plethory of applications: estimation problem is dynamic.
▶ Examples: target tracking–GNSS navigation–robotics.
▶ Question: how to define estimation methods taking into account a temporal
evolution of the unknown parameter ?
Objective
▶ Define a generic framework for online estimation problem ⇒ Bayesian filtering.
,→ Analytical approaches: Kalman filter-based approaches.
,→ Numerical approaches: Monte Carlo filter-based approaches.
2/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Principle
3/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Principle
4/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Application examples
→ GPS/GNSS navigation :
▶ Mobile position
estimation xk with
pseudo-distances
measurements zk .
▶ Pseudo-distances
computed between
mobile and every GNSS
satellite.
5/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Application examples
→ Radar tracking :
▶ Position estimation xk
of a target with radar
measurements
(distance, angle and
velocity)
▶ Measurements
computed by a radar
receiver (distance,
arrival angle).
Application examples
Prediction step:
7/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Application examples
Z
p(xk |z1:k−1 ) = p(xk , xk−1 |z1:k−1 )dxk−1
xk ∈Rp
Z
= p(xk |xk−1 ) p(xk−1 |z1:k−1 )dxk−1
xk−1 ∈Rp
8/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Application examples
Problem
▶ Distributions p(xk |xk−1 ) and p(zk |xk ) are generally known.
▶ BUT, without assumptions on p(xk−1 |z1:k−1 ), p(xk |z1:k−1 ) and p(xk |z1:k ) are
intractable.
Solutions
1- Assume a non-parametric based on samples drawn from the distribution
p(xk−1 |z1:k−1 ) → Monte-Carlo numerical approaches: Particle filter based-
methods.
2- Assume a parametric distribution on p(xk−1 |z1:k−1 ) → Analytical approaches:
Kalman filter based-methods.
9/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Application examples
10/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
11/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
12/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
such as: Z
p(xk |z1:k ) = p(x0:k |z1:k )dx0:k−1 (5)
N
1 X
p(x) ≃ δ(x − x(i) ) (6)
N
i=1
N
X p(x(i) )
p(x) ≃ δ(x − x(i) ) (7)
q(x(i) )
i=1
14/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
(i)
,→ Let {xk }N
i=1 ∼ q(x0:k |z1:k ): an approximation of p(x0:k |z1:k ) is given by:
N (i)
X p(x |z1:k ) 0:k (i)
p(x0:k |z1:k ) ≃ (i)
δ(x0:k − x0:k ) (8)
i=1
q(x0:k |z1:k )
▶ Then, we deduce an approximation of p(xk |z1:k ):
N
Z X (i)
p(x |z1:k ) 0:k (i)
p(xk |z1:k ) ≃ (i)
δ(x0:k − x0:k )dx0:k−1 (9)
i=1
q(x0:k |z1:k )
N (i)
X p(x |z1:k )
0:k (i)
= (i)
δ(xk − xk ) (10)
i=1
q(x0:k |z1:k )
(11)
15/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
(i)
p(x0:k |z1:k ) (i)
▶ corresponds to the importance weights denoted wk and:
(i)
q(x0:k |z1:k )
N
X (i) (i)
p(xk |z1:k ) ≃ wk δ(xk − xk ) (12)
i=1
▶ From that, we can extract two weighted MC estimators of the mean and the
covariance of p(xk |z1:k ) given by:
N
X (i) (i)
bxk|k ≃ wk x k (13)
i=1
N ⊤
X (i)
Pk|k ≃ wk bxk|k − xk(i) bxk|k − xk(i) (14)
i=1
16/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Particle filter
17/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Particle filter
Particle filter
Question
How to choose the importance density ?
18/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Particle filter
p(x0:k |z1:k ) =
p(xk |xk−1 ) p(zk |xk ) p(x0:k−1 |z1:k−1 ) q(xk |x0:k−1 , zk ) q(x0:k−1 |z1:k−1 )
q(xk |x0:k−1 , zk ) q(x0:k−1 |z1:k−1 )
R p(xk |xk−1 ) p(zk |xk ) p(x0:k−1 |z1:k−1 ) q(xk |x0:k−1 , zk ) q(x0:k−1 |z1:k−1 ) d x0:k
q(xk |x0:k−1 , zk ) q(x0:k−1 |z1:k−1 )
(15)
▶ If we have {xk (i) }Ns samples drawn from q(xk |x0:k−1 , zk ), then the MC
i=1
approximation of p is:
19/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Particle filter
Particle filter
We make appear:
(i)
(i) p(x0:k−1 |z1:k )
wk−1 = (i)
⇒ Importance weights computed at previous instant (16)
q(x0:k−1 |z1:k )
Then:
Ns p(x (i) |x(i) ) p(z |x (i) ) w (i)
P k k−1 k k k−1 (i)
(i)
δ(x0:k − x0:k )
i=1 q(xk (i) |x0:k−1 , zk )
p(x0:k |z1:k ) ≃
Ns p(x (i) |x(i) ) p(z |x (i) ) w (i)
P k k−1 k k k−1
(i)
i=1 q(xk (i) |x0:k−1 , zk )
20/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Particle filter
Particle filter
Thus:
Ns
X (i) (i)
p(x0:k |z1:k ) ≃ wk δ(x0:k − x0:k )
i=1
with:
(i) (i)
p(xk (i) |xk−1 ) p(zk |xk (i) ) wk−1
(i)
(i) q(xk (i) |x0:k−1 , zk )
wk =
Ns p(x (i) |x(i) ) p(z |x (i) ) w (i)
P k k−1 k k k−1
▶ This equation defines a weight recursion between w (i) and w (i) which allows to
k k−1
recursively update the posterior distribution.
▶ Advantage: any distribution don’t need to be Gaussian !
21/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Particle filter
22/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Particle filter
Ns
X (i)
bxk|k = wk xk (i)
i=1
23/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Particle filter
(i)
(i) p(zk |xk (i) ) wk−1
wk = (17)
Ns
P (i)
p(zk |xk (i) ) wk−1
i=1
▶ In this case, the particle filter is denoted SIS algorithm ( Sequential Importance
Sampling).
24/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Particle filter
SIS algorithm
Algorithm 2: SIS algorithm: summary
(i) (i)
Inputs: Samples (particles) and initial weights {x0 }Ns
i=1 , {w0 }, N : instants.
while k ≤ N do
→ Prediction step
while i ≤ Ns do
(i)
xk (i) ∼ p(xk |xk−1 )
→ Correction step
while i ≤ Ns do
(i)
Computation of the weights wk
. • Extraction of the estimated mean of p(xk |z1:k ).
Ns
X (i)
bxk|k = wk xk (i)
i=1
25/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Particle filter
Resampling
0.04
0.03
degeneration. 0.025
0.02
▶ Divergence.
Figure: Weight distribution:
Instant 1
0.4 1
0.9
0.35
0.8
0.3
0.7
0.25
0.6
0.2 0.5
0.4
0.15
0.3
0.1
0.2
0.05
0.1
0 0
0 0.5 1 1.5 2 0 0.5 1 1.5 2
26/52
Figure: Instant 2 Figure: Instant 50
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Particle filter
Resampling
▶ Solution:
1. resample the particles as follows:
Ns
(j)
X (i) (i)
x0:k ∼ wk δ(x0:k − x0:k )
i=1
Particle filter
SIR algorithm
Algorithm 3: SIR algorithm: summary
(i) (i)
Inputs: Initial particles and weights {x0 }Ns Ns
i=1 , {w0 }i=1 , N: instants.
while k ≤ N do
→ Prediction step
while i ≤ Ns do
(i)
Drawn xk (i) ∼ p(xk |xk−1 )
. → Correction step
while i ≤ Ns do
(i)
Computation of the weights wk according to the equation (17)
. → Resampling
If Neff ≤ γ
Ns
(⋆,j) P (i) (⋆,i)
1. x1:k ∼ wk δ(x0:k − x0:k ).
i=1
(j) 1
2. wk = ∀ j ∈ {1, . . . , Ns }.
Ns Ns
P (i)
bxk|k = wk xk (⋆,i)
i=1
28/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
29/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Assumptions
1- Gaussian linear assumption on p(xk |xk−1 ) and p(zk |xk )
with b
xk|k−1 and Pk|k−1 expressed as a function of b
xk−1|k−1 , and Pk−1|k−1 ,
• Second, that the corrected distribution is also Gaussian:
with b
xk|k and Pk|k expressed as a function of b
xk|k−1 , and Pk|k−1 ,
{b
xk−1|k−1 , Pk−1|k−1 } ⇒ {b
xk|k−1 , Pk|k−1 }
{b
xk|k−1 , Pk|k−1 } ⇒ {b
xk|k , Pk|k }
31/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
32/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Prediction step:
bxk|k−1 = Fk bxk−1|k−1
Pk|k−1 = Fk Pk−1|k−1 (Fk )⊤ + Qk
Correction step:
x̂k|k = bxk|k−1 + Kk zk − Hkbxk|k−1
Pk|k = (I − Kk Hk ) Pk|k−1
−1
Kk = Pk|k−1 (Hk )⊤ Hk Pk|k−1 H⊤
k + Rk
33/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Elements of proof
Prediction step:
Z
p(xk |z1:k−1 ) = p(xk , xk−1 |z1:k−1 )dxk−1
xk−1 ∈Rp
34/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Correction step:
Theorem
Let be a and b two Gaussian vectors on Rc and Rd such as:
h i h i h i
a ma Paa Pab
p(a, b) = NRc+d ,
b mb Pba Pbb
then:
p(a|b) = NRc a; ma|b , Pa|b
with:
ma|b = ma + Pab Pbb −1 (b − mb )
(20)
−1
Pa|b = Paa − Pab Pbb Pba (21)
35/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Elements of proof
with:
( −1
bxk|k = bxk|k−1 + Pk|k−1 (Hk )⊤ Hk Pk|k−1 Hk + Rk
zk − Hk b
xk|k−1 (22)
−1
Pk|k = Pk|k−1 − Pk|k−1 (Hk )⊤ Hk Pk|k−1 Hk + Rk Hk Pk|k−1 (23)
−1
• By noting Kk = Pk|k−1 (Hk )⊤ Hk Pk|k−1 Hk + Rk , we find correction step
equations.
36/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
37/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
▶ Classically, sensor and dynamic models are non-linear (but stay Gaussians !)
▶ Not possible to compute exactly the moments of p(xk |z1:k−1 ) et p(xk |z1:k )
▶ Solution : linear approximation of the models:
(
fk (xk−1 ) = fk (b
xk−1|k−1 ) + Jfk xk−1 − b
xk−1|k−1 (26)
hk (xk ) = hk (b
xk|k−1 ) + Jhk xk − b
xk|k−1 (27)
38/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
39/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Prediction step
(
bxk|k−1 = fk ( x̂k−1|k−1 )
⊤
Pk|k−1 = Jfk Pk−1|k−1 Jfk + Qk
Correction step
bxk|k = x̂k|k−1 + Kk zk − hk x̂k|k−1
Pk|k = (I − Kk Hk ) Pk|k−1
⊤ −1
Jhk Pk|k−1 J⊤
Kk = Pk|k−1 Jhk hk + Rk
40/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
41/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
42/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
IEKF: principle
How to derive this approximation i.e. means {b xk|k } and covariance matrices
xk|k−1 , b
{Pk|k−1 , Pk|k } ?
,→ Means obtained by computing the mode of both distributions.
,→ Covariance matrices are obtained by a second-order linearization around the
means.
,→ Fitting a Gaussian with these new parameters.
IEKF: method
• Non-linearities of the models → finding the mode of these distributions is not
feasible !
• Must be computed by minimization of a non-linear least squares criterion.
,→ Estimation problem ⇔ Optimization problem.
▶ In the same way as the EKF, the algorithm is divided in two steps: prediction
and correction.
43/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
• Computation of b
xk|k−1 :
▶ We want to resolve:
⋆
xk|k−1 = argmax p(xk |z1:k−1 ) (34)
xk
⋆ ⋆
⇔ xk|k−1 , xk−1|k−1 = argmax p(xk , xk−1 |z1:k−1 ) (35)
xk ,xk−1
where:
1 1
p(xk , xk−1 |z1:k−1 ) ∝ exp − ||xk − fk (xk−1 )||2Qk exp − ||xk−1 − xk−1|k−1 ||2P
2 2 k−1|k−1
44/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
⋆ ⋆
{xk|k−1 , xk−1|k−1 }= argmin − log p(xk , xk−1 |z1:k−1 )
x̃k ∈Rp ,x̃k−1 ∈Rp
1
= argmin ||xk − fk (xk−1 )||2Qk + ||xk−1 − b
xk−1|k−1 ||2P
xk ∈R ,xk−1 ∈R 2
p p k−1|k−1
Solutions of the optimization problem are trivial and are written as:
( ⋆
xk−1|k−1 =b
xk−1|k−1 (36)
⋆
xk|k−1 = fk (b
xk−1|k−1 ) ≜ b
xk|k−1 (37)
45/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
• Computation of Pk|k−1
J(xk , xk−1 ) = −2 log p(xk , xk−1 |z1:k−1 ) = ||ϕ(xk , xk−1 )||2Bk , (38)
⊤
ϕ(xk , xk−1 ) = xk − fk (xk−1 ), xk−1 − b
xk−1|k−1 (39)
h i
Qk 0
Bk = (40)
0 Pk−1|k−1
1
⋆ ⋆
p(xk , xk−1 ) ≃∝ exp − ||ϕ(xk|k−1 , xk−1|k−1 ) + Jϕ δ x ||2Bk (41)
2
1 ⊤ ⊤ −1
∝ exp − δ J B Jϕ δ x (42)
2 x ϕ k
⋆
with Jϕ Jacobian matrix of ϕ computed at xk|k−1 and:
⋆ ⋆
δ x = xk − xk|k−1 , xk−1 − xk−1|k−1 (43)
46/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
−1
−1
Pak|k−1 = J⊤
ϕ Bk Jϕ = A−1
k
.
▶ As (magic..):
Q−1 −Q−1 Jfk
h i
Pk|k−1 ...
Ak = ⊤ k −1 ⊤
k and Pak|k−1 = (44)
Jf Qk Jf Qk Jfk + Pk−1|k−1 ... ...
k k
we obtain (magic..):
Pk|k−1 = Jfk Pk−1|k−1 J⊤
fk + Qk (45)
Jfk : Jacobian matrix of fk computed at ⋆
xk−1|k−1 .
47/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
allows to obtain:
1 1
log p(xk |z1:k−1 ) = C2 + ||zk − hk (xk )||2Rk + ||xk − b
xk|k−1 ||2P (47)
2 2 k|k−1
where C2 ∈ R is a constant.
48/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
Computation of b
xk|k
▶ We look for the mode of p(xk |z1:k ).
▶ It is obtained by resolving the following optimization problem:
49/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
▶ At each iteration l:
(l) ⊤ (l) (l) ⊤
x(l+1) = x(l) − ( Jϕ Σ−1
k
Jϕ )−1 Jϕ Σ−1
k
ϕ(x(l) ) (51)
k k k
(l) (l)
Jh : Jacobian matrix of hk computed at x(l) , and Kk is the Kalman gain computed
k
at iteration l :
(l) (l) (l) (l)
Kk = Pk|k−1 (Jh )⊤ (Jh Pk−1|k−1 (Jh )⊤ + Rk )−1 (53)
k k k
−1
−1
Pk|k = J⊤
ϕ Σk Jϕ (54)
(
bxk|k−1 = fk ( x̂k−1|k−1 )
⊤
Pk|k−1 = Jfk Pk−1|k−1 Jfk + Qk
Correction step:
51/52
Estimation and identification IPSA
Online problem: Bayesian filter Bayesian filter: numerical approach Bayesian filter: analytical approaches
A few references..
52/52
Estimation and identification IPSA