comparison toolboxes/FullBNT-1.0.7/bnt/examples/dynamic/kjaerulff1.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 % Compare the speeds of various inference engines on the DBN in Kjaerulff
2 % "dHugin: A computational system for dynamic time-sliced {B}ayesian networks",
3 % Intl. J. Forecasting 11:89-111, 1995.
4 %
5 % The intra structure is (all arcs point downwards)
6 %
7 % 1 -> 2
8 % \ /
9 % 3
10 % |
11 % 4
12 % / \
13 % 5 6
14 % \ /
15 % 7
16 % |
17 % 8
18 %
19 % The inter structure is 1->1, 4->4, 8->8
20
21 seed = 0;
22 rand('state', seed);
23 randn('state', seed);
24
25 ss = 8;
26 intra = zeros(ss);
27 intra(1,[2 3])=1;
28 intra(2,3)=1;
29 intra(3,4)=1;
30 intra(4,[5 6])=1;
31 intra([5 6], 7)=1;
32 intra(7,8)=1;
33
34 inter = zeros(ss);
35 inter(1,1)=1;
36 inter(4,4)=1;
37 inter(8,8)=1;
38
39 ns = 2*ones(1,ss);
40 onodes = 2;
41 bnet = mk_dbn(intra, inter, ns, 'observed', onodes, 'eclass2', (1:ss)+ss);
42 for i=1:2*ss
43 bnet.CPD{i} = tabular_CPD(bnet, i);
44 end
45
46 T = 4;
47
48 engine = {};
49 engine{end+1} = jtree_unrolled_dbn_inf_engine(bnet, T);
50 engine{end+1} = jtree_dbn_inf_engine(bnet);
51 engine{end+1} = smoother_engine(jtree_2TBN_inf_engine(bnet));
52 %engine{end+1} = smoother_engine(hmm_2TBN_inf_engine(bnet)); % observed nodes have children
53
54 inf_time = cmp_inference_dbn(bnet, engine, T)
55 learning_time = cmp_learning_dbn(bnet, engine, T)