Verify if the kalman gain matrix K is working properly

control theoryestimationkalman filterlinear-controloptimal control

If I have a state space model.

$$x(k + 1) = Ax(k) + Bu(k)$$
$$y(k) = Cx(k) + Du(k)$$

And a kalman gain matrix $K$. Then, how do I know if the kalman gain matrix $K$ is properly designed for my state space model?

I know that I can use my kalman gain matrix $K$ as an observer.

$$\hat x(k + 1) = A\hat x(k) + Bu(k) + Ke(k)$$
$$\hat y(k) = C\hat x(k) + Du(k)$$

Where $e(k) = y(k) – \hat y(k)$ is a gaussian white noise with zero mean.

Question:

Assuming that I have the model of the system and I know the noise $e(k)$ and the input $u(k)$. Can I just simulate a regular state space model like this

$$\hat x(k + 1) = A\hat x(k) + \begin{bmatrix}
B & K
\end{bmatrix}\begin{bmatrix}
u(k) \\
e(k)
\end{bmatrix}$$

$$\hat y(k) = C\hat x(k) + Du(k)$$

And then measure how "clean" $\hat y(k)$ compared to $y(k)$?

Or is there any theoretical proof I can to to verify if the $K$ matrix is OK?

Update:

My question is about checking if the generated kalman gain matrix $K$ is "OK". What I mean by that, is that I want to check its accuracy. But I don't know how to specify the accuracy. I want the best filtering as possible, but I cannot specify the best filtering due to lack of something to refere to.

If I would describe my kalman filter with words, then a good estimation results looks like this. Here we have a very noisy sensor and the estimation is going to follow the original coordinate. The sum of all square errors is going to be as small as possible

$$J_{\text{min}} = \sum(\hat y – y_{\text{original coordinate}})^2 $$

Question remains: How can I test this condition if I have

  • The model
  • Kalman filter gain matrix $K$
  • Noise vector $e$
  • Trajectory $y$
  • Noisy trajectory $y_n$
  • Input signal $u$

enter image description here

Best Answer

I kindly think that you're not asking the right question. The Kalman gain matrix $K$ is a multiplication of three matrices, so if you multiply them correctly (which is trivial) it's correct by definition: $$ K_k = \hat{P}_k H_k S_k^{-1}, $$ where

  • $\hat{P}_k = F_k P_{k-1} F_k^T + Q_k$ is the predicted covariance matrix of the state,
  • $H_k$ is the observation model, and
  • $S_k = H_k \hat{P}_k H_k^T + R_k$ is the covariance of the innovation.

Now, what you want to know is if these three elements are correct. I recommend carefully reading the wiki KF page, which is very helpful imo.

In short:

  1. It is critical that you make sure that your matrices $F$, $B$ and $H$ correctly represent your system. They are usually derived analytically for each particular application.
  2. Please bear in mind that KF applications usually need a non-trivial step of fine tuning the covariance matrices for the system model and the sensor, $Q$ and $R$. The accuracy of the filter output is greatly influenced by their accuracies.