comparison toolboxes/FullBNT-1.0.7/bnt/general/convert_dbn_CPDs_to_tables_slow.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 function CPDpot = convert_dbn_CPDs_to_tables_slow(bnet, evidence)
2 % CONVERT_DBN_CPDS_TO_TABLES_SLOW Convert CPDs of (possibly instantiated) DBN nodes to tables
3 % CPDpot = convert_dbn_CPDs_to_tables_slow(bnet, evidence)
4 %
5 % CPDpot{n,t} is a table containing P(n,t|pa(n,t), ev)
6 % All hidden nodes are assumed to be discrete
7 %
8 % Non-vectorized method; this is less efficient for long sequences of observed Gaussian
9 % nodes, because of the (unnecessary) repeated matrix inversion.
10
11 obs_bitv = ~isemptycell(evidence(:));
12 [ss T] = size(evidence);
13 ns = bnet.node_sizes(:);
14
15 CPDpot = cell(ss,T);
16
17 t = 1;
18 for n=1:ss
19 %ps = engine.bnet_parents{n};
20 ps = parents(bnet.dag, n);
21 e = bnet.equiv_class(n, 1);
22 if ~any(obs_bitv(ps))
23 CPDpot{n,t} = convert_CPD_to_table_hidden_ps(bnet.CPD{e}, evidence{n,t});
24 else
25 CPDpot{n,t} = convert_to_table(bnet.CPD{e}, [ps n], evidence(:,1));
26 end
27 end
28 for t=2:T
29 for n=1:ss
30 self = n+ss;
31 ps = parents(bnet.dag, self);
32 e = bnet.equiv_class(n, 2);
33 if ~any(obs_bitv(ps))
34 CPDpot{n,t} = convert_CPD_to_table_hidden_ps(bnet.CPD{e}, evidence{n,t});
35 else
36 CPDpot{n,t} = convert_to_table(bnet.CPD{e}, [ps self], evidence(:,t-1:t));
37 end
38 end
39 end
40
41