# Kalman Filter Covariance

I've recently started playing with the Kalman filter for a simple 2D (x,y,dx,dy) tracking toy problem. But I seem to have some misunderstanding on what I can expect from the filter. I'm interested in plotting the uncertainty ellipse from the corrected covariance matrix but noticed a few observations:

• The covariance decreases to a steady state regardless of how much error I introduce into the measurement.

• The variance for x and y are exactly the same even though I introduce more measurement errors in y.

Staring at the maths for a bit it seems that this is how the vanilla Kalman Filter works. What I'm expecting is the opposite of the two points mentioned above. In the end I want to plot an uncertainty ellipse that reflects the error I'm observing. Is this possible at all? Do I have to do some post processing on the covariance matrix?

It occurred to me what I needed was a Kalman Filter that has the ability to adapt its covariance. I found this paper that details a few different methods to do this.

Evaluating the performances of adaptive Kalman filter methods in GPS/INS integration by Ali Almagbile, Jinling Wang, and Weidong Ding, 2010

• If you've found an answer, please post it as an answer and mark it as accepted. Thanks!
– Peter K.
May 12, 2015 at 7:53
• The link doesn't work. Could you write the title of the paper?
– Mark
Feb 23, 2021 at 5:39

The covariance matrix of a Kalman filter is a function of the $Q$ and $R$ matrices of the model.
If you use a model where $R$ and $Q$ are time invariant or known in prior then the calculation of the covariance matrix $P$ can be done offline and isn't a function of the measurements.

In some cases, advanced implementations of Kalman Filter estimate the covariances $R$ and $Q$ on line according to some data gathered in the process of calculating the result.

• I'm just learning about the Unscented Kalman Filter (UKF). It seems like the estimation of the predicted state covariance matrix needs to be done online. I thought the UKF would yield different estimates for the variances of x and y in some cases (e.g. dynamics moving only in the y direction). Should the UKF also yield identical estimates for variances for x and y? Dec 6, 2016 at 18:48
• Without knowing the model I can't say much. But if it is simple movement on 2D, why would you use UKF? UKF should be used for Non Linear Model. For instance measureing $r$ and $\theta$ instead of $x$ and $y$,
– Royi
Dec 6, 2016 at 18:57
• One reason to use the UKF might be to implement a single KF that supports both linear and non linear dynamic models. Let's just assume a simple constant acceleration dynamic model. Dec 6, 2016 at 20:11
• Would you open a new question with the whole model? Unless you show the non linear part of the model there is no point in UKF.
– Royi
Dec 7, 2016 at 6:03

The covariance decreases to a steady state regardless of how much error I introduce into the measurement.

Yes, as @Drazick notes, if the $Q$ and $R$ matrices are time invariant, then the $P$ matrix will converge to a steady state that does not depend on the data (measurements).

The variance for x and y are exactly the same even though I introduce more measurement errors in y.

When you did that, did you change the $R$ matrix to take account of this extra error in one component over the other? (I'm assuming you just used $x$ and $y$ as the measurements). If the $R$ matrix was chosen to be $\sigma I$, then you will not see any difference between $x$ and $y$ state variances.

Even the Wikipedia page on Kalman filtering mentions what you can do if you need to estimate $Q$ and $R$.