Daniel@0: function CPDpot = convert_dbn_CPDs_to_pots(bnet, evidence, pot_type, softCPDpot) Daniel@0: % CONVERT_DBN_CPDS_TO_POTS Convert CPDs of (possibly instantiated) DBN nodes to potentials Daniel@0: % CPDpot = convert_dbn_CPDs_to_pots(bnet, evidence, pot_type, softCPDpot) Daniel@0: % Daniel@0: % CPDpot{n,t} is a potential containing P(n,t|pa(n,t), ev) Daniel@0: % softCPDpot{n,t} is a potential containing P(n,t|pa(n,t), ev) insted of using n's CPD Daniel@0: Daniel@0: [ss T] = size(evidence); Daniel@0: Daniel@0: if nargin < 4, softCPDpot = cell(ss,T); end Daniel@0: CPDpot = softCPDpot; Daniel@0: Daniel@0: % Convert CPDs of instantiated nodes to potential form Daniel@0: t = 1; Daniel@0: for n=1:ss Daniel@0: fam = family(bnet.dag, n); Daniel@0: e = bnet.equiv_class(n, 1); Daniel@0: if isempty(softCPDpot{n,t}) Daniel@0: CPDpot{n,t} = convert_to_pot(bnet.CPD{e}, pot_type, fam(:), evidence(:,1)); Daniel@0: end Daniel@0: end Daniel@0: for n=1:ss Daniel@0: fam = family(bnet.dag, n, 2); Daniel@0: e = bnet.equiv_class(n, 2); Daniel@0: for t=2:T Daniel@0: if isempty(softCPDpot{n,t}) Daniel@0: CPDpot{n,t} = convert_to_pot(bnet.CPD{e}, pot_type, fam(:), evidence(:,t-1:t)); Daniel@0: end Daniel@0: end Daniel@0: end