forked from IDM-UWB/Survey-of-Noise-Covariance-Estimation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTOMBM.m
68 lines (60 loc) · 2.28 KB
/
TOMBM.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function [est] = TOMBM(sys,z,param)
%TOMBM (sys,z,param) Third Order Moment Bayesian Method
%
% 3OMBM - Section 4.3
%
% based on:
% D. M. Wiberg, T. D. Powel, D. Ljungquist, "An on-line parameter
% estimator for quick convergence and time-varying linear systems",
% IEEE Transactions on Automatic Control, vol. 45, no. 10, pp. 1854-1863,
% 2000.
%
% estimates Q
% SYS.F, SYS.H nad SYS.R are system matrices
% Z is nz/N matrix of measurements from N time instants
% PARAM.XP, PARAM.PP describes initial estimate of the state and its variance
% PARAM.RHO, PARAM.PIF initial weights for basis matrices and their variance
% PARAM.QA basis matrices for Q
N = size(z,2); % obtain number of measurements
nx = size(sys.F,2); % obtain state dimension
aN = length(param.Qa);
%Initial parameters
xp = param.xp; %x0
Pp = param.Pp; %Px0
hp = zeros(nx,aN);
rho = param.rho; % parameter values
pif = param.pif; % parameter values variance
Wp = cell(1,aN);
Wf = cell(1,aN);
for j = 1:aN
Wp{j} = eye(nx);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%% STEP I - COMPUTE MEANS, CMs and 3rd ORDER MOMENTS
for i = 1:N
e = z(:,i) - sys.H*xp; %innovation
V = sys.R+sys.H*Pp*sys.H'; %innovation covariance matrix
K = Pp*sys.H'/V; %filter gain
xf = xp + K*e; %state estimate measurement update
Pf = (eye(nx)-K*sys.H)*Pp; % state CM measurement update
for j = 1:aN
% filtering
rho(j) = rho(j)+hp(:,j)'*sys.H'/V*e; % parameter values
pif(j) = pif(j)-hp(:,j)'*sys.H'/V*sys.H*hp(:,j);%parameter values variance
hp(:,j) = (eye(nx)-K*sys.H)*(hp(:,j)+Wp{j}*sys.H'/V*e); % par. values gain
Wf{j} = (eye(nx)-K*sys.H)*Wp{j}*(eye(nx)-K*sys.H)'; % 3rd order moment
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% STEP II - ESTIMATE Q
Qh = zeros(nx);
for j = 1:aN
Qh = Qh+param.Qa{j}*rho(j); %merge estimate Q
end
% prediction
xp = sys.F*xf; %state estimate predictive update
Pp = sys.F*Pf*sys.F' + Qh; % predictive covariance update
% parameters time update
for j = 1:aN
hp(:,j) = sys.F*hp(:,j);
Wp{j} = sys.F*Wf{j}*sys.F'+param.Qa{j}*pif(j);
end
end;
est.Q = Qh;