Jump to content

  • Log In with Google      Sign In   
  • Create Account


Kalman filter without using matrix inverse


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 yahastu   Members   -  Reputation: 152

Like
1Likes
Like

Posted 12 September 2013 - 03:23 PM

Kalman filter predict/update equations are here:

https://en.wikipedia.org/wiki/Kalman_filter

 

I have implemented the Kalman filter and it works nicely.  However,  the standard Kalman equations are written naively in terms of the matrix inverse.  In particular, the S matrix (innovation covariance) is inverted in order to compute K (the gain matrix):

S = H P H^t + R
K = P H^t S^{-1}

The gain matrix (K) is finally used to update the state estimate (x) and estimated covariance of the state (P) as follows:

x += K y
P -= K H P

I would like to update 'x' and 'P' without computing the matrix inverse S^{-1}.

In the following reference, a method is given "for calculating (H P H^t + R)^{-1} H in the conventional Kalman filter without explicitly computing an inverse." (using U D U^T, or LDL^t)  Of course, (H P H^t + R)^{-1} is equal to S^{-1}, but this confuses me because "S^{-1} H" does not appear in the computation of K....and so, it is not clear to me, how the value of S^{-1}H can be used to compute K.

Reference:
'Kalman Filtering; Theory and Practice Using MATLAB', second edition, by Grewal and Andrews
http://books.google.com/books?id=sZbxLK-NKb0C&q=+without+explicitly+inverting#v=snippet&q=without%20explicitly%20inverting&f=false
(click the second link)


Edited by yahastu, 12 September 2013 - 03:39 PM.


Sponsor:

#2 Brother Bob   Moderators   -  Reputation: 7774

Like
1Likes
Like

Posted 12 September 2013 - 03:46 PM

In these types of recursive algorithms involving updates and matrix inverse you can often eliminate the inverse with the Matrix Inversion Lemma, also known as the Woodbury identity or variations thereof. It basically gives you a formula for recursively updating the inverse of a matrix directly instead of updating the matrix and then inverting it every iteration.

 

That information may help you on the way, although I am not even sure if it is possible to use the MIL in this case.



#3 Álvaro   Crossbones+   -  Reputation: 11859

Like
0Likes
Like

Posted 12 September 2013 - 07:02 PM

Of course, (H P H^t + R)^{-1} is equal to S^{-1}, but this confuses me because "S^{-1} H" does not appear in the computation of K....and so, it is not clear to me, how the value of S^{-1}H can be used to compute K.


I haven't read the formulas for the Kalman filter in a while, so I might be missing something, but if S is symmetric (which it should be, since it's a covariance matrix of some sort), the transpose of (S^{-1} H) is (H^t S^{-1}), which you can use to compute K.

#4 Inferiarum   Members   -  Reputation: 723

Like
0Likes
Like

Posted 13 September 2013 - 01:11 AM

Kalman filter predict/update equations are here:

https://en.wikipedia.org/wiki/Kalman_filter

 

I have implemented the Kalman filter and it works nicely.  However,  the standard Kalman equations are written naively in terms of the matrix inverse.  In particular, the S matrix (innovation covariance) is inverted in order to compute K (the gain matrix):

S = H P H^t + R
K = P H^t S^{-1}

The gain matrix (K) is finally used to update the state estimate (x) and estimated covariance of the state (P) as follows:

x += K y
P -= K H P

I would like to update 'x' and 'P' without computing the matrix inverse S^{-1}.

In the following reference, a method is given "for calculating (H P H^t + R)^{-1} H in the conventional Kalman filter without explicitly computing an inverse." (using U D U^T, or LDL^t)  Of course, (H P H^t + R)^{-1} is equal to S^{-1}, but this confuses me because "S^{-1} H" does not appear in the computation of K....and so, it is not clear to me, how the value of S^{-1}H can be used to compute K.

Reference:
'Kalman Filtering; Theory and Practice Using MATLAB', second edition, by Grewal and Andrews
http://books.google.com/books?id=sZbxLK-NKb0C&q=+without+explicitly+inverting#v=snippet&q=without%20explicitly%20inverting&f=false
(click the second link)

 

You have K = P H^t S^{-1} = P X^t, where X is the solution to the linear system of equations

S X = H

now this could be solved by calculating X = S^-1 H which is, however, not the most efficient solution.

Since in your case S is positive definite, you can use the Cholesky decomposition to solve it.

More information on wikipedia.



#5 Inferiarum   Members   -  Reputation: 723

Like
0Likes
Like

Posted 13 September 2013 - 01:20 AM

I you are using lapack to do the linear algebra stuff, the functions dpotrf and dpotrs will do what you need here.



#6 Emergent   Members   -  Reputation: 967

Like
1Likes
Like

Posted 14 September 2013 - 07:47 AM

There are three forms of the Kalman filter.  You might consider using another form,

 

There's the covariance form, which you are using.  This requires a matrix inversion at each step, but gives you the state estimate directly.  This is the form most people know.

 

There's also an information form, which works with the inverse of the covariance matrix (called the (Fisher) information matrix).  This does not require a matrix inversion at each step -- but the state estimate is not directly accessible. Instead of a state estimate, you have an information vector.  You can reconstruct the state estimate from the information vector, but this requires a matrix inverse.  One nice thing about this form is that you can specify a totally noninformative prior for the state by setting the initial information matrix to zero.  Also, there are reasonable assumptions under which information matrices are sparse (but covariance matrices are not), so this form can sometimes be efficient for really large problems with sparsity.

 

Finally, there's the square root form.  Here, instead of working with either the covariance or its inverse, you work with a matrix square root of the covariance matrix (e.g., its Cholesky decomposition), and actually never construct the covariance matrix directly.  This is usually the most computationally efficient filter. [EDIT: Actually, it's the most expensive; what it is is numerically stable.]  It also avoid the problems of ensuring that your covariance or information matrix remain positive definite in the face of roundoff errors, since it's impossible to represent anything but positive definite matrices this way [EDIT: this is largely the point of this form].


Edited by Emergent, 14 September 2013 - 08:02 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS