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