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