8
$\begingroup$

I have recently started working on the unscented Kalman filter. I coded the numerically stable version (i.e., square root Kalman filter) and used MATLAB for implementing. In the final update step, where we update the state covariance matrix using cholupdate I get an error.

Pk = cholupdate(expected_S,K*Sy,'-')

Basically, expected_S'*expected_S-(K*Sy)*(K*Sy)' is not positive semi-definite (where expected_P=expected_S'*expected_S;) and so cholupdate returns an error.

I cannot understand why this is happening in the square root implementation. (I have checked the derivations and coding didn't seem to find an error.)

PS: I am currently testing linear models on UKF just to check if its optimal for linear models, but I keep getting the above error (for local linear trend model).

$\endgroup$
5
  • 3
    $\begingroup$ This is probably due to some numerical instability (that is: your derivations are probably correct, just an issue with losing precision from repeated computations) which tends to occur when dealing with covariance matrices. There are a few tricks that may help you out - for starters, have a look at stats.stackexchange.com/questions/6364/… $\endgroup$
    – Nick
    Jan 21, 2013 at 20:24
  • $\begingroup$ Hi Nick, Thanks. I did what you suggested. It works but not in all cases. The results I get are ok and I can work with them. But even if I set the non zero eigen values to 0 it doesnt gaurantee a semi positive definite matrix. What I would like to understand or do is a) How to avoid this permanently or b) How to know which cases it will work and which it wont.... Any thoughts on this would really be helpful... Again Thanks. $\endgroup$
    – Sharad
    Jan 27, 2013 at 19:34
  • 1
    $\begingroup$ Yea, this is definitely a work-around. I typically set the negative eigenvalues to 1e-8 (or some small positive value). I'm not sure this problem is avoidable, especially when you're doing repeated operations on a covariance matrix due to the imprecision of floating point variables. $\endgroup$
    – Nick
    Jan 27, 2013 at 19:54
  • $\begingroup$ aah...Thanks. I will do some more testing and revert to you. $\endgroup$
    – Sharad
    Jan 28, 2013 at 10:06
  • 1
    $\begingroup$ This question appears to be off-topic because it is about coding. $\endgroup$ Sep 11, 2013 at 17:07

1 Answer 1

0
$\begingroup$

I also have this problem. However, I realised that depending on the covariance that you fix, it does not happen. If I set an unrealistic covariance matrix, then the error happens. Which makes me think that is perhaps a matter of numerical errors making the covariance matrix non-positive definite.

However, as you say, in the SRUKF in its normal behaviour, this should not happen at all, the covariance matrix is ensured to be symmetric and semi-positive definite.

I would suggest a test. Try to measure the covariance of the data, and then set those values.

I hope it helps!

$\endgroup$
2
  • $\begingroup$ I don't know what cholupdate does, but, if you are having numerical problems, it's best to calculate these quantities using first principles of the kalman update. For a small problem like local linear trend, it shouldn't be difficult to do that. Then, if you do that and still get an error, it's easier to find the error. I try to not use the black boxy function until the simple case works both ways: .black box way and fundamental way. $\endgroup$
    – mlofton
    Oct 28, 2018 at 5:40
  • $\begingroup$ also, the others answers are worth emphasizing. if you choose an initial covariance matrix that is way different than the one used in its update, that will cause numerical issues. So, it should be of the same order of magnitude. $\endgroup$
    – mlofton
    Oct 28, 2018 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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