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