comparison toolboxes/FullBNT-1.0.7/bnt/examples/dynamic/scg_dbn.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 % Test whether stable conditional Gaussian inference works
2 % Make a linear dynamical system
3 % X1 -> X2
4 % | |
5 % v v
6 % Y1 Y2
7
8 intra = zeros(2);
9 intra(1,2) = 1;
10 inter = zeros(2);
11 inter(1,1) = 1;
12 n = 2;
13
14 X = 2; % size of hidden state
15 Y = 2; % size of observable state
16
17 ns = [X Y];
18 bnet = mk_dbn(intra, inter, ns, 'discrete', [], 'observed', 2);
19
20 x0 = rand(X,1);
21 V0 = eye(X);
22 C0 = rand(Y,X);
23 R0 = eye(Y);
24 A0 = rand(X,X);
25 Q0 = eye(X);
26
27 bnet.CPD{1} = gaussian_CPD(bnet, 1, 'mean', x0, 'cov', V0);
28 bnet.CPD{2} = gaussian_CPD(bnet, 2, 'mean', zeros(Y,1), 'cov', R0, 'weights', C0);
29 bnet.CPD{3} = gaussian_CPD(bnet, 3, 'mean', zeros(X,1), 'cov', Q0, 'weights', A0);
30
31
32 T = 5; % fixed length sequences
33
34 engine = {};
35 engine{end+1} = kalman_inf_engine(bnet);
36 engine{end+1} = scg_unrolled_dbn_inf_engine(bnet, T);
37 engine{end+1} = jtree_unrolled_dbn_inf_engine(bnet, T);
38
39 inf_time = cmp_inference_dbn(bnet, engine, T, 'check_ll', 0);