comparison toolboxes/FullBNT-1.0.7/bnt/examples/static/SCG/scg3.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 various inference engines on the following network (from Jensen (1996) p84 fig 4.17)
2 % 1
3 % / | \
4 % 2 3 4
5 % | | |
6 % 5 6 7
7 % \/ \/
8 % 8 9
9 % where all arcs point downwards
10
11 N = 9;
12 dag = zeros(N,N);
13 dag(1,2)=1; dag(1,3)=1; dag(1,4)=1;
14 dag(2,5)=1; dag(3,6)=1; dag(4,7)=1;
15 dag(5,8)=1; dag(6,8)=1; dag(6,9)=1; dag(7,9) = 1;
16
17 gauss = 1;
18 if gauss
19 ns = ones(1,N); % scalar nodes
20 ns(1) = 2;
21 ns(9) = 3;
22 dnodes = [];
23 else
24 ns = 2*ones(1,N); % binary nodes
25 dnodes = 1:N;
26 end
27
28 bnet = mk_bnet(dag, ns, 'discrete', dnodes);
29 % use random params
30 for i=1:N
31 if gauss
32 bnet.CPD{i} = gaussian_CPD(bnet, i);
33 else
34 bnet.CPD{i} = tabular_CPD(bnet, i);
35 end
36 end
37
38 engines = {};
39 engines{1} = jtree_inf_engine(bnet);
40 engines{2} = stab_cond_gauss_inf_engine(bnet);
41
42 [err, time] = cmp_inference_static(bnet, engines);