comparison toolboxes/FullBNT-1.0.7/bnt/CPDs/@discrete_CPD/Old/prob_CPD.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:cc4b1211e677
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