Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/Kalman/AR_to_SS.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function [F,H,Q,R,initx, initV] = AR_to_SS(coef, C, y) | |
2 % | |
3 % Convert a vector auto-regressive model of order k to state-space form. | |
4 % [F,H,Q,R] = AR_to_SS(coef, C, y) | |
5 % | |
6 % X(i) = A(1) X(i-1) + ... + A(k) X(i-k+1) + v, where v ~ N(0, C) | |
7 % and A(i) = coef(:,:,i) is the weight matrix for i steps ago. | |
8 % We initialize the state vector with [y(:,k)' ... y(:,1)']', since | |
9 % the state vector stores [X(i) ... X(i-k+1)]' in order. | |
10 | |
11 [s s2 k] = size(coef); % s is the size of the state vector | |
12 bs = s * ones(1,k); % size of each block | |
13 | |
14 F = zeros(s*k); | |
15 for i=1:k | |
16 F(block(1,bs), block(i,bs)) = coef(:,:,i); | |
17 end | |
18 for i=1:k-1 | |
19 F(block(i+1,bs), block(i,bs)) = eye(s); | |
20 end | |
21 | |
22 H = zeros(1*s, k*s); | |
23 % we get to see the most recent component of the state vector | |
24 H(block(1,bs), block(1,bs)) = eye(s); | |
25 %for i=1:k | |
26 % H(block(1,bs), block(i,bs)) = eye(s); | |
27 %end | |
28 | |
29 Q = zeros(k*s); | |
30 Q(block(1,bs), block(1,bs)) = C; | |
31 | |
32 R = zeros(s); | |
33 | |
34 initx = zeros(k*s, 1); | |
35 for i=1:k | |
36 initx(block(i,bs)) = y(:, k-i+1); % concatenate the first k observation vectors | |
37 end | |
38 | |
39 initV = zeros(k*s); % no uncertainty about the state (since perfectly observable) |