Daniel@0: % Compare the speeds of various inference engines on the DBN in Kjaerulff Daniel@0: % "dHugin: A computational system for dynamic time-sliced {B}ayesian networks", Daniel@0: % Intl. J. Forecasting 11:89-111, 1995. Daniel@0: % Daniel@0: % The intra structure is (all arcs point downwards) Daniel@0: % Daniel@0: % 1 -> 2 Daniel@0: % \ / Daniel@0: % 3 Daniel@0: % | Daniel@0: % 4 Daniel@0: % / \ Daniel@0: % 5 6 Daniel@0: % \ / Daniel@0: % 7 Daniel@0: % | Daniel@0: % 8 Daniel@0: % Daniel@0: % The inter structure is 1->1, 4->4, 8->8 Daniel@0: Daniel@0: seed = 0; Daniel@0: rand('state', seed); Daniel@0: randn('state', seed); Daniel@0: Daniel@0: ss = 8; Daniel@0: intra = zeros(ss); Daniel@0: intra(1,[2 3])=1; Daniel@0: intra(2,3)=1; Daniel@0: intra(3,4)=1; Daniel@0: intra(4,[5 6])=1; Daniel@0: intra([5 6], 7)=1; Daniel@0: intra(7,8)=1; Daniel@0: Daniel@0: inter = zeros(ss); Daniel@0: inter(1,1)=1; Daniel@0: inter(4,4)=1; Daniel@0: inter(8,8)=1; Daniel@0: Daniel@0: ns = 2*ones(1,ss); Daniel@0: onodes = 2; Daniel@0: bnet = mk_dbn(intra, inter, ns, 'observed', onodes, 'eclass2', (1:ss)+ss); Daniel@0: for i=1:2*ss Daniel@0: bnet.CPD{i} = tabular_CPD(bnet, i); Daniel@0: end Daniel@0: Daniel@0: T = 4; Daniel@0: Daniel@0: engine = {}; Daniel@0: engine{end+1} = jtree_unrolled_dbn_inf_engine(bnet, T); Daniel@0: engine{end+1} = jtree_dbn_inf_engine(bnet); Daniel@0: engine{end+1} = smoother_engine(jtree_2TBN_inf_engine(bnet)); Daniel@0: %engine{end+1} = smoother_engine(hmm_2TBN_inf_engine(bnet)); % observed nodes have children Daniel@0: Daniel@0: inf_time = cmp_inference_dbn(bnet, engine, T) Daniel@0: learning_time = cmp_learning_dbn(bnet, engine, T)