annotate toolboxes/FullBNT-1.0.7/bnt/potentials/check_for_cd_arcs.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 check_for_cd_arcs(onodes, cnodes, dag)
wolffd@0 2 % CHECK_FOR_CD_ARCS Raise an error if there are any C->D links where the C node is hidden.
wolffd@0 3 % check_for_cd_arcs(onodes, cnodes, dag)
wolffd@0 4 %
wolffd@0 5 % We cannot convert the logistic/softmax function (C->D CPD) to a Gaussian potential
wolffd@0 6 % unless we use the variational approximation discussed in
wolffd@0 7 % "A variational approximation for Bayesian networks with discrete and continuous latent
wolffd@0 8 % variables", K. Murphy, UAI 1999.
wolffd@0 9
wolffd@0 10 n = length(dag);
wolffd@0 11 hnodes = mysetdiff(1:n, onodes);
wolffd@0 12 chid = myintersect(cnodes, hnodes);
wolffd@0 13 dnodes = mysetdiff(1:n, cnodes);
wolffd@0 14 for i=chid(:)'
wolffd@0 15 dcs = myintersect(children(dag, i), dnodes);
wolffd@0 16 if ~isempty(dcs)
wolffd@0 17 error(['hidden cts node ' num2str(i) ' has a discrete child']);
wolffd@0 18 end
wolffd@0 19 end
wolffd@0 20
wolffd@0 21
wolffd@0 22
wolffd@0 23