# The final step in kalman filter to correct/update the covariance matrix

I see that, in the correction step of Kalman filter, there is an equation to update the covariance matrix. I have been using it in the form:

P = (I - KH)P'

Here P is the covariance matrix, K is the Kalman Gain and H is the observation model. The I is the identity matrix. However, I also see a different equation in some literature:

P = P' - KSKT

where

S = HPHT + Q

where Q is the noise matrix for the observation model. Are these two equations same? If so, how to prove it?

• After discussion on my answer now I see the confusion. There's an identity I'm missing somewhere I think but I can't figure it out so I removed my answer. FYI, as a sanity check it might be worth setting up a script to generate random matrices, compute optimal $K$, and then compute both $P$ updates to see if they are equal. Mar 22 '18 at 16:46
• @ryan0270 That's a good idea. I will do that. However, it would be much more satisfying if we could find a mathematical proof. Mar 22 '18 at 16:48
• The proof is only useful if the random tests all come back the same. If those tests start to show differences than you know for sure the two are not equivalent (or there are missed assumptions) Mar 22 '18 at 18:22

The Kalman Gain is defined as the following:

$K = PH^T (HPH^T + Q)^-1$

From your question, we need to prove:

$P - KSK^T = (I - KH)P$

primes omitted for simplicity

Canceling P, and substitute S with the provided definition:

$K (HPH^T + Q)K^T = KHP$

Substitute the first K on the left hand side with the definition of the Kalman gain provided: $PH^T (HPH^T + Q)^-1 (HPH^T + Q)K^T = KHP$

S and it's inverse reduces to identity, we are left with:

$PH^TK^T = KHP$

From the transpose property of matrices $(ABC)^T = C^T B^T A^T$ we can rearrange LHS with $P$ as $A$, $H^T$ as $B$, and $K^T$ as $C$:

$(KHP^T)^T = KHP$

Since covariance matrix is symmetric, and KHP must be symmetric (this can be inferred from $P' = P - KHP$) therefore:

$KHP = KHP$

• When you go from second last to the last step, isn't it $PH^TK^T = KHP$? Correct me if I am wrong. Mar 22 '18 at 20:09
• I missed a transpose at the last steps in my original answer and edited just before your comment. Are you referring to the original answer or the edit? Mar 22 '18 at 20:13
• To the edit, with the missed transpose. Mar 22 '18 at 20:14
• How did you arrive at $PH^TK^T$? Mar 22 '18 at 20:15
• $KHP$ is symmetric, as is $P$ Mar 22 '18 at 20:21