# How to set initial values of the elements in the covariance matrices in the Kalman filter?

Let's say I would like to use the discrete version of the Kalman filter in a role of a state observer of a linear dynamic system. The observed continuous time domain dynamic system can be described with following state space model:

$$\begin{eqnarray} \dot{\mathbf{x}} &=& {\mathbf{A}}\cdot{\mathbf{x}} + {\mathbf{B}}\cdot{\mathbf{u}} \\ {\mathbf{y}} &=& {\mathbf{C}}\cdot{\mathbf{x}} \end{eqnarray}$$

where the system matrix $${\mathbf{A}}$$ is $$[4\times 4]$$, the input matrix $${\mathbf{B}}$$ is $$[4\times 2]$$ and the output matrix $${\mathbf{C}}$$ is $$[2\times 4]$$.

My question is how I should set the initial values of:

• the elements of the covariance matrix of the model noise $${\mathbf{Q}}$$ $$[4\times 4]$$
• the elements of the covariance matrix of the measurement noise $${\mathbf{R}}$$ $$[2\times 2]$$
• the elements of the covariance matrix of the estimate error $${\mathbf{P}}$$ $$[4\times 4]$$

It is worthwhile to say that I have no statistical information neither about the model noise nor the measurement noise. Is it ever possible to come up with some reasonable initial values in such circumstances? Thanks in advance.

Unless you have a really good idea of the initial covariance and you have a strong need to have the filter give really good really early results, it's not a bad idea to set $$\mathbf P = b \mathbf I$$, where $$b$$* is the largest number you can use without causing numerical problems as the filter settles.
Technically, you can't really make a true Kalman filter without knowing $$\mathbf Q$$ and $$\mathbf R$$ directly. In practice, it's not at all uncommon to make something that has the form of a Kalman filter, but uses guesses for $$\mathbf Q$$ and $$\mathbf R$$. Practical values for these matrices are found by cut and try (tell you're boss that you're 'tuning', or if you really need to impress, that you're "applying a heuristic").
While you really want to make some effort to find $$\mathbf Q$$ and $$\mathbf R$$, if you don't mind doing even more math you may want to look into H-infinity filtering. Depending on your opinions, it's either a variant of or a cousin to the Kalman filter. It takes more computation to come up with a solution, but it is more robust to errors introduced by not knowing either the process dynamics or the statistics of the measurement and process noise.
Handing an H-infinity filter the wrong values for $$\mathbf Q$$ and $$\mathbf R$$ may not give you the right filter, but it may give you a less wrong filter than a Kalman formulation.
* $$b$$ chosen here because it meets the technical definition of a bazillion: it's a really large, vaguely defined, yet still knowable and finite number. It's sort of the practicing engineer's version of infinity.