Solved – Unscented Kalman filter-negative covariance matrix

bayesiancomputational-statisticskalman filtermachine learningsignal processing

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).

Best Answer

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!