comparison toolboxes/FullBNT-1.0.7/bnt/examples/static/Belprop/belprop_polytree_discrete.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 % Make the following polytree, where all arcs point down
2
3 % 1 2
4 % \ /
5 % 3
6 % / \
7 % 4 5
8
9 N = 5;
10 dag = zeros(N,N);
11 dag(1,3) = 1;
12 dag(2,3) = 1;
13 dag(3, [4 5]) = 1;
14
15 ns = 2*ones(1,N); % binary nodes
16
17 onodes = [1 5];
18
19 bnet = mk_bnet(dag, ns, 'observed', onodes);
20
21 if 0
22 seed = 0;
23 rand('state', seed);
24 randn('state', seed);
25 end
26
27 for i=1:N
28 %bnet.CPD{i} = tabular_CPD(bnet, i);
29 bnet.CPD{i} = noisyor_CPD(bnet, i);
30 end
31
32 engine = {};
33 engine{end+1} = jtree_inf_engine(bnet);
34 engine{end+1} = pearl_inf_engine(bnet, 'protocol', 'tree');
35 engine{end+1} = pearl_inf_engine(bnet, 'protocol', 'parallel');
36
37 [err, time] = cmp_inference_static(bnet, engine, 'maximize', 0, 'check_ll', 1);
38