# 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. Commented Mar 22, 2018 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.
– skr
Commented Mar 22, 2018 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) Commented Mar 22, 2018 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.
– skr
Commented Mar 22, 2018 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? Commented Mar 22, 2018 at 20:13
• To the edit, with the missed transpose.
– skr
Commented Mar 22, 2018 at 20:14
• How did you arrive at $PH^TK^T$? Commented Mar 22, 2018 at 20:15
• $KHP$ is symmetric, as is $P$ Commented Mar 22, 2018 at 20:21
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}