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