comparison toolboxes/FullBNT-1.0.7/bnt/CPDs/@discrete_CPD/Old/prob_CPD.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 p = prob_CPD(CPD, domain, ns, cnodes, evidence)
2 % PROB_CPD Compute prob of a node given evidence on the parents (discrete)
3 % p = prob_CPD(CPD, domain, ns, cnodes, evidence)
4 %
5 % domain is the domain of CPD.
6 % node_sizes(i) is the size of node i.
7 % cnodes = all the cts nodes
8 % evidence{i} is the evidence on the i'th node.
9
10 ps = domain(1:end-1);
11 self = domain(end);
12 CPT = CPD_to_CPT(CPD);
13
14 if isempty(ps)
15 T = CPT;
16 else
17 assert(~any(isemptycell(evidence(ps))));
18 pvals = cat(1, evidence{ps});
19 i = subv2ind(ns(ps), pvals(:)');
20 T = reshape(CPT, [prod(ns(ps)) ns(self)]);
21 T = T(i,:);
22 end
23 p = T(evidence{self});
24
25