annotate toolboxes/FullBNT-1.0.7/bnt/general/compute_joint_pot.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 [jpot, loglik] = compute_joint_pot(bnet, nodes, evidence, domain)
wolffd@0 2 % COMPUTE_JOINT_POT Compute the global joint potential of a Bayes net
wolffd@0 3 % function jpot = compute_joint_pot(bnet, nodes, evidence, domain)
wolffd@0 4
wolffd@0 5 if nargin < 4, domain = nodes; end
wolffd@0 6
wolffd@0 7 onodes = find(~isemptycell(evidence));
wolffd@0 8 pot_type = determine_pot_type(bnet, onodes, domain);
wolffd@0 9
wolffd@0 10 jpot = mk_initial_pot(pot_type, domain, bnet.node_sizes, bnet.cnodes, onodes);
wolffd@0 11 for i=nodes(:)'
wolffd@0 12 e = bnet.equiv_class(i);
wolffd@0 13 fam = family(bnet.dag, i);
wolffd@0 14 pot = convert_to_pot(bnet.CPD{e}, pot_type, fam(:), evidence);
wolffd@0 15 jpot = multiply_by_pot(jpot, pot);
wolffd@0 16 end
wolffd@0 17 %[jpot, loglik] = normalize_pot(jpot); % causes errors in asia_dt1 etc