# Why is Qk not included in the cost function that is optimised by the Kalman filter?

Assume the following linear discrete system:

$x_k = Fx_{k-1} + w_{k-1}$ where $w_{k} \sim N(0, Q)$

$y_k = Hx_k + v_{k}$ where $v_{k} \sim N(0, R)$

One way to prove that the Kalman filter is optimal is to show that it minimises the following cost function:

$J_m = \frac{1}{2}(y_k - Hx_k)^TR^{-1}(y_k - Hx_k) + \frac{1}{2}(x_k - Fx_{k-1})^TP_{k|k-1}^{-1}(x_k - Fx_{k-1})$

Why do we use $P_{k|k-1}$ instead of Q as the covariance in the second part of $J_m$? By the way, $P_{k|k-1}$ is the covariance of estimation

• Hi: Assuming that $M$ is the variance of the state variable $x_{k}$ and that $Q$ is the variance of $w$, , then $M$ is included because $Q$ is the variance of $w$ so the formula for $M$ will have $Q$ in it. This is because at any update , $M$ is a function of the variance of the state ( often referred to as $C$ but notations vary ) and $Q$. I'm not sure if this answers your question. It's best to explain what $M$ and $Q$ are because the notation is often not consistent. – mlofton Sep 8 '18 at 17:34
• If we know $x_{k-1}$, then isn't the variance of $x_k$ just Q instead of M? – Vykta Wakandigara Sep 8 '18 at 17:39
• Hi: Since this is a KF, then you never actually know $x_{k}$. It's a state that has a variance associated with it at each step $k$. It's best to read up on how the kalman filter update is derived. Then you will see what I mean more clearly. – mlofton Sep 9 '18 at 19:32
• I have made the appropriate edits – Vykta Wakandigara Sep 10 '18 at 18:34

## 1 Answer

Because you are using Bayes' theorem (and conditional independence):

$$p(x_k \mid y_{1:k}) \propto p(y_k \mid x_k) p(x_k \mid y_{1:k-1}).$$ Note that, regarding the observation density: $$p(y_k \mid x_k) \propto \exp\left[-\frac{1}{2}(y_k - Hx_k)^TR^{-1}(y_k - Hx_k) \right].$$ Also, the "prior" for the state, or the state prediction density is $$p(x_k \mid y_{1:k-1}) \propto \exp\left[-\frac{1}{2}(x_k - Fx_{k-1})^TP_{k \mid k-1}^{-1}(x_k - Fx_{k-1}) \right].$$

You do not use $Q$ because that is the covariance matrix for the state transition distribution $p(x_k \mid x_{k-1})$. However, you would use $Q$ in the calculation of $P_{k \mid k-1}$ because that state prediction density can be written in terms of your outdated filtering distribution, and the state transition distribution: $$p(x_k \mid y_{1:k-1}) = \int p(x_k \mid x_{k-1})p(x_{k-1} \mid y_{1:k-1}) dx_{k-1}.$$