You are on page 1of 4

1

Deriving Kalman Filter Algorithm

We assume that we observe a process zt at discrete times t = t0 , t1 , . . . , and that z follows zt = Ht xt + vt , where Ht is an observed design matrix, v are iid vectors of normally distributed noise with covariance, R and mean 0. The above equation is the observation equation. It is determined by the state variable, x , which we assume follows xt = Axt1 + wt1 . This is the state space equation, and, as in the observation equation, we have a design matrix, A, and iid normally distributed vectors, w , with mean 0 and covariance Q. Without getting into the ner points here, one can develop the necessary independence amongst the lagged ws, vs, and zs fairly readily. Our goal is to determine the value for x at a given time based on all information up to that time. We will assume that this information set (technically a Hilbert space) is determined by It = {zt , zt1 , . . . , z0 , xt , xt1 , . . . , x0 }. We will call estimates of the state based on the current information set, say, It , a posteriori estimates of the state, and estimates based on the one-step lagged It1 a priori estimates. We will denote the a posteriori and a priori estimates at time t by xt and x respectively. Formally, we have t xt = E(xt | It ) x = E(xt | It1 ). t We also dene a posteriori and a priori errors given by et = xt xt e = xt x , t t with corresponding error covariance matrices Pt and Pt , Pt = E(et et ) Pt = E(e e ). t t 1

The goal of the Kalman lter is to determine an a posteriori state estimate which minimizes the a posteriori error covariance. We further assume that the a posteriori state is determined from the dierence of the most current a priori state estimate and a linear combination of the most recent observation and the most recent predicted observation; viz., minimize subject to Pt xt = x + Kt (zt Ht x ). t t

Here, Kt is the matrix solution to the optimization problem so dened, and is called the Kalman gain. It has a closed form solution given by Kt = Pt Ht (Ht Pt H + R)1 . Proof In the proof that follows, we will denote the matrix multiplication yy , for vectors, y, by y 2 , and we will drop the subscript t on the matrices Kt and Ht . We will also use I to represent the identity matrix. Pt = Pt (K) = = = = = = = E(et et ) = E(et )2 E(xt xt K(zt H x ))2 t E(xt (I KH)t Kzt )2 x E(xt (I KH) KHxt Kvt )2 xt E((I KH)(xt x ) Kvt )2 t E((I KH)et Kvt )2 (I KH)Pt (I KH) + KRK .

In this last line, we used the orthogonality of e and vt . Expanding, we nd, t Pt = Pt KHPt Pt H K + KHPt H K + KRK . We next take the trace of both sides and nd the gradient with respect to K:
K tr(Pt )

= Pt H Pt H + 2KHPt H + 2KR.

Setting the left hand side to zero and solving the resulting equation for K yields the desired result. 2

Using the Kalman gain matrix, we are able to update the a posteriori state variable. This can be seen as a measurement update since a new observation is required to obtain this new state. We may also project forward in time to obtain a new a priori state estimate prior to any new information. This may be seen as a time update equation. To do this, we take a conditional expectation of the state space equation, x = E(xt | It1 ) t = E(Axt1 + wt1 | It1 ) = At1 , x where we have assumed that w I for all . We also have an estimate of the a priori error covariance that can be obtained prior to the arrival of new information. In a manner similar to that just shown, we have, using the same squared notation as above, Pt = = = = = E(e e | It1 ) t t E((xt x )2 | It1 ) t E((Axt1 + wt1 At1 )2 | It1 ) x 2 E((Aet1 + wt1 ) | It1 ) APt1 A + Q.

In the last line, we use the orthogonality of e and w . We are only left to update the a posteriori covariance matrix, Pt . This will again be a measurement update equation, using the information set It . We have from before (again omitting some subscripts) that Pt = (I KH)Pt (I KH) + KRK = Pt KHPt Pt H K + K(HPt H + R)K Using the fact that K = Pt Ht (Ht Pt H + R)1 , this becomes Pt = Pt KHPt Pt H K Pt H K = (I KH)Pt .

Putting all of this together, we have the Kalman lter algorithm: i x = At1 t x ii Pt = APt1 A + Q iii Kt = Pt Ht (Ht Pt Ht + R)1 iv xt = x + Kt (zt Ht x ) t t v Pt = (I Kt Ht )Pt . Notice that i ii are the a priori, time update equations, and iii v are the a posteriori, measurement update equations. The lter estimates the state process and then obtains feedback in the form of observations.

You might also like