4
$\begingroup$

I am implementing my own discrete Kalman filter to estimate velocity from acceleration and position measurements (using Matlab ).

I think I managed to deal with the $R$ matrix (measurements noise covariance matrix) in this way:

M = [x;x2dot];
R = cov(M);

What I am not sure about is the matrix $Q$.

In all the examples I found on the web and on this website also, the values inside that matrix are really really small. Moreover, I found here this statement:

if you select an overly large Q, then it doesn’t seem like the Kalman filter would be well-behaved.

The fact is that, in my model, to obtain acceptable results I used values in the order of $1e6$ on the diagonal of the $Q$ matrix.

In this way I got the estimated displacement equal to the measured one and the estimated acceleration equal to the measured one. The velocity is in the right range of values but it still looks noisy.

So the question is: is there a limit for the values to be used in $Q$?

And also, are there guidelines to choose those values?

EDIT

Last question, does the $Q$ matrix have to be diagonal or it can be full also?

$\endgroup$
  • $\begingroup$ Please see the reports arXiv:1503.04313v1.pdf, arXiv:1505.07201v1.pdf and arXiv:1505.07208v1.pdf. and the papers in SADHANA December 2016 issues. $\endgroup$ – ANANTHASAYANAM Apr 20 '17 at 9:01
6
$\begingroup$

First and foremost I really recommend this great textbook project about Kalman filtering. You can find some words about setting the process noise here. There is also a pdf version of it.

In every step the filter estimates a multivariate normal distribution with parameters $\mu = x$ (state vector) and $\sigma = P$ (covariance matrix).

By looking the Kalman filter equations you can see that $Q$ is added to the predicted $FPF^T$. By doing this we 'artificially' smear the new normal distribution, increasing the uncertainty of our prediction. It also means that we raise the probabilities of the state vectors near $x$.

So if you choose $Q$ with huge values compared to those of $P$ you essentially say that the model does a bad job predicting the process and we really have to extend the range we think the true state vector lies in.

You are free to choose a full matrix to be $Q$ as long as it is a valid covariance matrix. A diagonal $Q$ means that your state parameters are independent from each other. The section about the multivariate normal distribution can give you more insight as well as examples.

$\endgroup$
  • $\begingroup$ Thank you for all the useful links. I managed to make it work using a non-diagonal $Q$ matrix. Just one more question: when you say "You are free to choose a full matrix to be Q as long as it is a valid covariance matrix", what do you mean with "valid covariance matrix"? $\endgroup$ – Rhei Mar 1 '15 at 13:37
  • 2
    $\begingroup$ A covariance matrix is a symmetric positive-semidefinite one. en.wikipedia.org/wiki/… $\endgroup$ – Bálint Fodor Mar 1 '15 at 16:41
  • $\begingroup$ great textbook indeed... $\endgroup$ – Anurag Priyadarshi Apr 4 '16 at 12:46
  • 2
    $\begingroup$ Updated link to the pdf (provided by the author) $\endgroup$ – anderstood Aug 25 '16 at 16:09
9
$\begingroup$

I'm the author of the textbook linked to above. This is a new account and thus I am not allowed to reply to that answer.

Anyway, the Gaussian chapter covers the definition of a covariance matrix. In general though your Q matrix will be full, not a diagonal, because there is correlation between the state variables. For example, suppose you are tracking position and velocity in x-axis for a car. Process noise (which Q is modelling) might be things like wind, bumps in the road, and so on. If there is a change in velocity due to this noise, there will also be a change in position. They are correlated, and so the off-diagonal elements will be non-zero for those terms.

The Kalman math chapter tells you how to compute the Q matrix for various scenarios. Admittedly there is more work to be done on that section. It's one of the more opaque subjects as most sources either gloss over it or just throw an integral at you and expect you to figure out the rest.

Finally, the companion FilterPy project contains code to compute the full Q matrix for you given common scenarios. The code is in common/discretization. For analytically difficult situations there is a routine to find the result numerically following an idea from Golub and Van Loan; the textbook is lacking on this topic, however.

$\endgroup$
  • 1
    $\begingroup$ Roger, that book looks great! $\endgroup$ – Peter K. Nov 27 '15 at 17:48
2
$\begingroup$

Ask your self what the plant noise is being used to model/represent. The usual suspects are the effects of unmodelled states and/or random drift in the model parameters (which could be the same thing but just treated differently). If you can answer that question you can make an attempt at deriving an appropriate plant nose co-variance yourself.

The other approach is trial and error.

$\endgroup$
  • $\begingroup$ Still I would not know what order of magnitude I should use. What do high /low values in $Q$ mean? $\endgroup$ – Rhei Feb 28 '15 at 12:09
  • 1
    $\begingroup$ The plant noise serves to stabilize (in a sense) the filter against becoming over confident in its estimate of the state. Low $Q$ indicates confidence that any unknown noise terms and/or modelling errors are small to negligible. Higher $Q$ allows the tracker to follow the state despite unknown noise and/or model errors. $\endgroup$ – Conrad Turner Feb 28 '15 at 15:45
0
$\begingroup$

you may have noticed a method, variance component estimation (VCE). One usual has the Q and R diagonal. The VCE can estimate the variance components for the individual measurements and for the individual noise factors in the process noise vector using the measurement residuals and process noise residuals.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.