3 ms·
When implementing Kalman filters a common issue is that the covariance matrix P retards to be not positive semi-definite due to numerical errors. When this happ
by xaedes 6y ago
When implementing Kalman filters a common issue is that the covariance matrix P retards to be not positive semi-definite due to numerical errors. When this happens the Kalman filter may result REALLY weird results.
There is an easy fix for this that is rarely mentioned, except one runs into this issue and googles it:
After updating (prediction and observation) P just ensure its positive semi-definiteness by averaging with its transpose:
P := (P+transpose(P))/2
- rmrfstar 6y agoWhat you have recommended will tend to stabilize the covariance matrix, but not for the reason you have given. If numerical stability is an issue you encounter, I would caution against using it. Try [1] instead. You imply that any symmetric matrix is positive semi-definite. Take an orthogonal matrix U and a diagonal matrix D with one or more negative values. P = U * D * U.T is symmetric but not positive semi-definite. For example, if D[0,0] = -1 then U[:, 0].T * P * U[:,0] = -1. [1] https://en.wikipedia.org/wiki/Kalman_filter#Square_root_form https://en.wikipedia.org/wiki/Kalman_filter#Square_root_form