annotate toolboxes/FullBNT-1.0.7/bnt/general/convert_dbn_CPDs_to_tables_slow.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function CPDpot = convert_dbn_CPDs_to_tables_slow(bnet, evidence)
Daniel@0 2 % CONVERT_DBN_CPDS_TO_TABLES_SLOW Convert CPDs of (possibly instantiated) DBN nodes to tables
Daniel@0 3 % CPDpot = convert_dbn_CPDs_to_tables_slow(bnet, evidence)
Daniel@0 4 %
Daniel@0 5 % CPDpot{n,t} is a table containing P(n,t|pa(n,t), ev)
Daniel@0 6 % All hidden nodes are assumed to be discrete
Daniel@0 7 %
Daniel@0 8 % Non-vectorized method; this is less efficient for long sequences of observed Gaussian
Daniel@0 9 % nodes, because of the (unnecessary) repeated matrix inversion.
Daniel@0 10
Daniel@0 11 obs_bitv = ~isemptycell(evidence(:));
Daniel@0 12 [ss T] = size(evidence);
Daniel@0 13 ns = bnet.node_sizes(:);
Daniel@0 14
Daniel@0 15 CPDpot = cell(ss,T);
Daniel@0 16
Daniel@0 17 t = 1;
Daniel@0 18 for n=1:ss
Daniel@0 19 %ps = engine.bnet_parents{n};
Daniel@0 20 ps = parents(bnet.dag, n);
Daniel@0 21 e = bnet.equiv_class(n, 1);
Daniel@0 22 if ~any(obs_bitv(ps))
Daniel@0 23 CPDpot{n,t} = convert_CPD_to_table_hidden_ps(bnet.CPD{e}, evidence{n,t});
Daniel@0 24 else
Daniel@0 25 CPDpot{n,t} = convert_to_table(bnet.CPD{e}, [ps n], evidence(:,1));
Daniel@0 26 end
Daniel@0 27 end
Daniel@0 28 for t=2:T
Daniel@0 29 for n=1:ss
Daniel@0 30 self = n+ss;
Daniel@0 31 ps = parents(bnet.dag, self);
Daniel@0 32 e = bnet.equiv_class(n, 2);
Daniel@0 33 if ~any(obs_bitv(ps))
Daniel@0 34 CPDpot{n,t} = convert_CPD_to_table_hidden_ps(bnet.CPD{e}, evidence{n,t});
Daniel@0 35 else
Daniel@0 36 CPDpot{n,t} = convert_to_table(bnet.CPD{e}, [ps self], evidence(:,t-1:t));
Daniel@0 37 end
Daniel@0 38 end
Daniel@0 39 end
Daniel@0 40
Daniel@0 41