• Nenhum resultado encontrado

PDF Derivation of Kalman Filtering and Smoothing Equations

N/A
N/A
Protected

Academic year: 2023

Share "PDF Derivation of Kalman Filtering and Smoothing Equations"

Copied!
5
0
0

Texto

(1)

Derivation of Kalman Filtering and Smoothing Equations

Byron M. Yu

Department of Electrical Engineering Stanford University

Stanford, CA 94305, USA byronyu@stanford.edu

Krishna V. Shenoy

Department of Electrical Engineering Neurosciences Program

Stanford University Stanford, CA 94305, USA

shenoy@stanford.edu

Maneesh Sahani

Gatsby Computational Neuroscience Unit University College London

17 Queen Square, London WC1N 3AR, UK maneesh@gatsby.ucl.ac.uk

October 19, 2004

Abstract

The Kalman filtering and smoothing problems can be solved by a series of forward and backward recursions, as presented in [1]–[3]. Here, we show how to derive these relationships from first principles.

1 Introduction

We consider linear time-invariant dynamical systems (LDS) of the following form:

xt+1 =Axt +wt (1)

yt =Cxt+vt (2)

wherext and yt are the state and output, respectively, at timet. The noise terms, wt and vt, are zero-mean normally-distributed random variables with covariance matrices Qand R, respectively.

The initial state, x1, is normally-distributed with meanπ1 and variance V1.

In this work, we assume that the parameters of the linear dynamical system, namely A, C, Q, R, π1, and V1 are known. Whereas the outputs are observed, the state and noise variables are hidden.

The goal is to determineP(xt|{y}t1) andP(xt|{y}T1) fort= 1, . . . , T. These are the solutions to the filtering and smoothing problems, respectively. Both distributions are normally-distributed for the system described by (1) and (2), so it suffices to find the mean and variance of each distribution.

(2)

We will use the same notation as in [1]. E(xt|{y}τ1) is denoted by xτt and Var(xt|{y}τ1) is denoted by Vtτ. The sequence of T outputs (y1,y2, . . . ,yT) is denoted by {y}. A subsequence of outputs (yt0,yt0+1, . . . ,yt1) is denoted by{y}tt10.

2 Forward Recursions: Filtering

By the assumptions of the LDS described by (1) and (2),P(xt|{y}t1) is a normal distribution. We seek its meanxtt and variance Vtt.

logP(xt|{y}t1) = logP(xt|{y}t11,yt)

= logP(yt|xt,{y}t11) + log P(xt|{y}t11) +. . .

= logP(yt|xt) + logP(xt|{y}t11) +. . .

=−1

2(yt−Cxt)0R1(yt−Cxt)−1

2(xt−xtt1)0(Vtt1)1(xt−xtt1) +. . .

=−1

2x0t C0R1C+ (Vtt1)1

xt+x0t C0R1yt+ (Vtt1)1xtt1

+. . . (3) Note that, in general, ifz is normally-distributed with meanµand variance Σ,

logP(z) =−1

2(z−µ)0Σ1(z−µ) +. . .

=−1

2z0Σ1z+z01µ) +. . . (4) Comparing the first terms in (3) and (4) and using the Matrix Inversion Lemma,

Vtt = C0R1C+ (Vtt1)11

=Vtt1−KtCVtt1 (5)

where

Kt =Vtt1C0 R+CVtt1C01

. (6)

To find the time update for the variance, we use the fact that Axt1 andwt1 are independent Vtt1 = Var(Axt1|{y}t11) + Var(wt1|{y}t11)

=AVtt11A0+Q. (7)

Before finding the mean of the normal distribution, we derive the following matrix identity (A+B)1(A+B) =I

I−(A+B)1A= (A+B)1B

(I−(A+B)1A)B1 = (A+B)1. (8) Comparing the second terms in (3) and (4) and applying the matrix identity (8),

xtt=Vtt C0R1yt+ (Vtt1)1xtt1

=Vtt1C0

I− R+CVtt1C01

CVtt1C0

R1yt+ (I−KtC)xtt1

=Vtt1C0 R+CVtt1C01

yt+ (I−KtC)xtt1

=Ktyt+ (I−KtC)xtt1

=xtt1+Kt(yt−Cxtt1). (9)

(3)

The time update for the mean can be found by conditioning onxt1

xtt1=Ext1 E(xt|xt1,{y}t11)

{y}t11

=Ext

1 Axt1

{y}t11

=Axtt11. (10)

The recursions start withx011 and V10 =V1. Equations (5), (6), (7), (9), and (10) together form the Kalman filter forward recursions, as shown in [1].

3 Backward Recursions: Smoothing

Like the filtered posterior distributionP(xt|{y}t1), the smoothed posterior distributionP(xt|{y}T1) is also normal. We seek its meanxTt and variance VtT. We are also interested in the covariance of the joint posterior distributionP(xt+1,xt|{y}T1), denotedVt+1,tT .

log P(xt+1,xt|{y}T1) = logP(xt|xt+1,{y}T1) + logP(xt+1|{y}T1)

= logP(xt|xt+1,{y}t1) + log P(xt+1|{y}T1)

= logP(xt+1|xt) + log P(xt|{y}t1)−logP(xt+1|{y}t1) + logP(xt+1|{y}T1)

=−1

2(xt+1−Axt)0Q1(xt+1−Axt)−1

2(xt−xtt)0(Vtt)1(xt−xtt) +1

2(xt+1−xtt+1)0(Vt+1t )1(xt+1−xtt+1)

−1

2(xt+1−xTt+1)0(Vt+1T )1(xt+1−xTt+1) +. . .

=−1

2x0t+1 Q1−(Vt+1t )1+ (Vt+1T )1 xt+1

−1

2x0t+1(−Q1A)xt−1

2x0t(−A0Q1)xt+1

−1

2x0t A0Q1A+ (Vtt)1

xt+x0t (Vtt)1xtt

+. . . (11)

Note that, in general, if [z01 z02]0 is normally-distributed with mean [µ01 µ02]0, then the log density can be expressed in the form

logP(z1,z2) =−1 2

z1−µ1

z2−µ2 0

S11 S12

S21 S22

z1−µ1

z2−µ2

+. . .

=−1

2z01S11z1−1

2z01S12z2−1

2z02S21z1− 1

2z02S22z2+z02(S21µ1+S22µ2) +. . . (12) The covariance of [z01 z02]0 is

Σ11 Σ12

Σ21 Σ22

=

S11 S12

S21 S22

1

=

F111 −F111S12S221

−S221S21F111 F221

(13)

=

S111+S111S12F221S21S111 −F111S12S221

−S221S21F111 S221+S221S21F111S12S221

, (14)

(4)

where

F11=S11−S12S221S21

F22=S22−S21S111S12. Comparing the first four terms in (11) and (12), we can write

Vt+1T Vt+1,tT Vt,t+1T VtT

=

Q1−(Vt+1t )1+ (Vt+1T )1 −Q1A

−A0Q1 A0Q1A+ (Vtt)1 1

(15) We first simplify two expressions that will appear when inverting the block matrix in (15). First, using the Matrix Inversion Lemma,

S221 = A0Q1A+ (Vtt)11

=Vtt−VttA0(Vt+1t )1AVtt

=Vtt−JtVt+1t Jt0, (16)

where we define

Jt =VttA0(Vt+1t )1. (17) Second, applying the matrix identity (8),

S221S21=−(Vtt−JtVt+1t Jt0)A0Q1

=−VttA0 I−(Q+AVttA0)1AVttA0 Q1

=−VttA0(Q+AVttA0)1

=−Jt. (18)

Now, we invert the block matrix in (15). Using (16),(18), and the fact that F111 =Vt+1T from (13), VtT =S221+S221S21F111S12S221

= (Vtt−JtVt+1t Jt0) + (−Jt)Vt+1T (−Jt0)

=Vtt+Jt(Vt+1T −Vt+1t )Jt0 (19) and

Vt+1,tT =−F111S12S221

=Vt+1T Jt0. (20)

Using (17), (19), and (20), we can also derive a recursive formulation for the covariance Vt,tT1=VtTJt01

= Vtt+Jt(Vt+1T −Vt+1t )Jt0 Jt01

= Vtt+Jt(Vt+1,tT −AVtt) Jt01

=VttJt01+Jt(Vt+1,tT −AVtt)Jt01. (21)

Using (5), (17), and (20), this recursion is initialized with VT ,TT 1=VTTJT01

= (I−KTC)VTT1JT01

= (I−KTC)AVTT11. (22)

(5)

To find the mean, we compare the last terms in (11) and (12). Using (16), (17), and (18), S21xTt+1+S22xTt = (Vtt)1xtt

xTt =−S221S21xTt+1+S221(Vtt)1xtt

=JtxTt+1+ (I−JtA)xtt

=xtt+Jt(xTt+1−Axtt). (23) Equations (17), (19), (21), (22), and (23) together form the Kalman smoother backward recur- sions, as shown in [1]. Equivalently, (20) can be used in the place of (21) and (22) to reduce the computation required to find the covariance.

References

[1] Z. Ghahramani and G.E. Hinton. Parameter estimation for linear dynamical systems. Technical Report CRG-TR-96-2, University of Toronto, 1996.

[2] R.H. Shumway and D.S. Stoffer. An approach to time series smoothing and forecasting using the EM algorithm. Journal of Time Series Analysis, 3(4):253–264, 1982.

[3] B.D.O. Anderson and J.B. Moore. Optimal Filtering. Prentice-Hall, Englewood Cliffs, NJ, 1979.

Referências

Documentos relacionados

Resultados e Discussão As cascas de Macadâmia adquiridas na Região de Umuarama-PR, foram trituradas e peneiradas, sendo submetidas a um tratamento com NaOH e ácido cítrico, tendo