wolffd@0
|
1 function CPDpot = convert_dbn_CPDs_to_pots(bnet, evidence, pot_type, softCPDpot)
|
wolffd@0
|
2 % CONVERT_DBN_CPDS_TO_POTS Convert CPDs of (possibly instantiated) DBN nodes to potentials
|
wolffd@0
|
3 % CPDpot = convert_dbn_CPDs_to_pots(bnet, evidence, pot_type, softCPDpot)
|
wolffd@0
|
4 %
|
wolffd@0
|
5 % CPDpot{n,t} is a potential containing P(n,t|pa(n,t), ev)
|
wolffd@0
|
6 % softCPDpot{n,t} is a potential containing P(n,t|pa(n,t), ev) insted of using n's CPD
|
wolffd@0
|
7
|
wolffd@0
|
8 [ss T] = size(evidence);
|
wolffd@0
|
9
|
wolffd@0
|
10 if nargin < 4, softCPDpot = cell(ss,T); end
|
wolffd@0
|
11 CPDpot = softCPDpot;
|
wolffd@0
|
12
|
wolffd@0
|
13 % Convert CPDs of instantiated nodes to potential form
|
wolffd@0
|
14 t = 1;
|
wolffd@0
|
15 for n=1:ss
|
wolffd@0
|
16 fam = family(bnet.dag, n);
|
wolffd@0
|
17 e = bnet.equiv_class(n, 1);
|
wolffd@0
|
18 if isempty(softCPDpot{n,t})
|
wolffd@0
|
19 CPDpot{n,t} = convert_to_pot(bnet.CPD{e}, pot_type, fam(:), evidence(:,1));
|
wolffd@0
|
20 end
|
wolffd@0
|
21 end
|
wolffd@0
|
22 for n=1:ss
|
wolffd@0
|
23 fam = family(bnet.dag, n, 2);
|
wolffd@0
|
24 e = bnet.equiv_class(n, 2);
|
wolffd@0
|
25 for t=2:T
|
wolffd@0
|
26 if isempty(softCPDpot{n,t})
|
wolffd@0
|
27 CPDpot{n,t} = convert_to_pot(bnet.CPD{e}, pot_type, fam(:), evidence(:,t-1:t));
|
wolffd@0
|
28 end
|
wolffd@0
|
29 end
|
wolffd@0
|
30 end
|