wolffd@0
|
1 function [xsmooth, Vsmooth, VVsmooth_future] = smooth_update(xsmooth_future, Vsmooth_future, ...
|
wolffd@0
|
2 xfilt, Vfilt, Vfilt_future, VVfilt_future, A, Q, B, u)
|
wolffd@0
|
3 % One step of the backwards RTS smoothing equations.
|
wolffd@0
|
4 % function [xsmooth, Vsmooth, VVsmooth_future] = smooth_update(xsmooth_future, Vsmooth_future, ...
|
wolffd@0
|
5 % xfilt, Vfilt, Vfilt_future, VVfilt_future, A, B, u)
|
wolffd@0
|
6 %
|
wolffd@0
|
7 % INPUTS:
|
wolffd@0
|
8 % xsmooth_future = E[X_t+1|T]
|
wolffd@0
|
9 % Vsmooth_future = Cov[X_t+1|T]
|
wolffd@0
|
10 % xfilt = E[X_t|t]
|
wolffd@0
|
11 % Vfilt = Cov[X_t|t]
|
wolffd@0
|
12 % Vfilt_future = Cov[X_t+1|t+1]
|
wolffd@0
|
13 % VVfilt_future = Cov[X_t+1,X_t|t+1]
|
wolffd@0
|
14 % A = system matrix for time t+1
|
wolffd@0
|
15 % Q = system covariance for time t+1
|
wolffd@0
|
16 % B = input matrix for time t+1 (or [] if none)
|
wolffd@0
|
17 % u = input vector for time t+1 (or [] if none)
|
wolffd@0
|
18 %
|
wolffd@0
|
19 % OUTPUTS:
|
wolffd@0
|
20 % xsmooth = E[X_t|T]
|
wolffd@0
|
21 % Vsmooth = Cov[X_t|T]
|
wolffd@0
|
22 % VVsmooth_future = Cov[X_t+1,X_t|T]
|
wolffd@0
|
23
|
wolffd@0
|
24 %xpred = E[X(t+1) | t]
|
wolffd@0
|
25 if isempty(B)
|
wolffd@0
|
26 xpred = A*xfilt;
|
wolffd@0
|
27 else
|
wolffd@0
|
28 xpred = A*xfilt + B*u;
|
wolffd@0
|
29 end
|
wolffd@0
|
30 Vpred = A*Vfilt*A' + Q; % Vpred = Cov[X(t+1) | t]
|
wolffd@0
|
31 J = Vfilt * A' * inv(Vpred); % smoother gain matrix
|
wolffd@0
|
32 xsmooth = xfilt + J*(xsmooth_future - xpred);
|
wolffd@0
|
33 Vsmooth = Vfilt + J*(Vsmooth_future - Vpred)*J';
|
wolffd@0
|
34 VVsmooth_future = VVfilt_future + (Vsmooth_future - Vfilt_future)*inv(Vfilt_future)*VVfilt_future;
|
wolffd@0
|
35
|
wolffd@0
|
36
|