about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/BNT/general/compute_joint_pot.m
blob: 056aa998a37d4c39127f7f9a7f357d17c4840b96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function [jpot, loglik] = compute_joint_pot(bnet, nodes, evidence, domain)
% COMPUTE_JOINT_POT Compute the global joint potential of a Bayes net
% function jpot = compute_joint_pot(bnet, nodes, evidence, domain)

if nargin < 4, domain = nodes; end

onodes = find(~isemptycell(evidence));
pot_type = determine_pot_type(bnet, onodes, domain);

jpot = mk_initial_pot(pot_type, domain, bnet.node_sizes, bnet.cnodes, onodes);
for i=nodes(:)'
  e = bnet.equiv_class(i);
  fam = family(bnet.dag, i);
  pot = convert_to_pot(bnet.CPD{e}, pot_type, fam(:), evidence);
  jpot = multiply_by_pot(jpot, pot);
end                                                  
%[jpot, loglik] = normalize_pot(jpot); % causes errors in asia_dt1 etc