Non positive state covariance using squared unscented Kalman Filter
19 次查看(过去 30 天)
显示 更早的评论
Hi,
i am trying to use an unscented kalman filter for state and parameter estimation of an ode.
And i am using the UKF-Function from Yi Ciao posted here on Matlab Central: https://de.mathworks.com/matlabcentral/fileexchange/18217-learning-the-unscented-kalman-filter
When trying to run this i get always the same error, that says that my Covariance Matrix P (or S for the squared UKF) becomes non positive definite and therefore the cholesky factorisation does not work. I have already tried a modified version of Ciao's code that implements a squared UKF found on github (https://github.com/JJHu1993/sr-ukf/blob/master/ukf.m).
For me it is unclear what is causing a non positive definite covariance at all. And if that is something that can be fixed by adjusting the tunable parameters (alpha,ki,beta). I found out that for both (ukf and sr-ukf) the code works if i choose alpha = 1 however then the state estimation is really bad. For any value for alpha smaller than 1 i receive the mentioned error. I tried this for two different models/functions and got the same behaviour.
I would be very glad if someone could answer me these questions:
- What is typically causing the covariance to become non-positive definite?
- Is this something that depends on the tunable parameters or is there a problem with the used model or even the observability?
- What is the typical procedure for this problem?
Thanks a lot in advance.
1 个评论
Huy
2024-6-6
Dear Jonas,
I can understand your difficulty for this issue!
It used to be my largest concern when I first met UKF!
You can use this tiny function from Mr. John D'Errico here to deal with it but please read the Review session with my comment - Huy:
You can add nearestSPD function into the UKF function of Mr. Yi Cao and add 1 more code line following below:
function X=sigmas(x,P,c)
%Sigma points around reference point
%Inputs:
% x: reference point
% P: covariance
% c: coefficient
%Output:
% X: Sigma points
P = nearestSPD(P);
A = c*chol(P)';
Y = x(:,ones(1,numel(x)));
X = [x Y+A Y-A];
Hope this solution can solve your problem!
回答(1 个)
nick
2024-1-30
Hi Jonas,
I understand from your query that you are interested in finding out why the covariance matrix might become non-positive definite and whether tunable parameters affect it.
A covariance matrix becoming non-positive definite can be caused by several factors:
- Numerical Instabilities: When the UKF equations are solved using finite-precision arithmetic (as is the case in computer implementations), small numerical errors can accumulate and lead to a loss of positive definiteness.
- Improper Tuning Parameters: The UKF has several parameters, such as alpha, beta, and kappa (or ki), which control the spread of the sigma points around the mean state estimate and the confidence in the process and measurement noise covariance matrices. If these are not chosen correctly, they can lead to an ill-conditioned covariance matrix.
- Model Mismatch: If the process model or the measurement model used in the UKF does not accurately represent the true system dynamics or measurement process, it can lead to incorrect covariance updates.
- Poor Observability: If the system or the measurements do not provide enough information to fully observe the state of the system, it can make the covariance matrix estimation unreliable.
Regarding the tunable parameters, when the system response to a varying parameter is slow, a larger value for alpha might be required to maintain stability. If you are encountering stability issues, you may consider working with the Square Root UKF, which is computationally more stable.
Hope this helps.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!