Daniel@0: function T = convert_to_table(CPD, domain, evidence) Daniel@0: % CONVERT_TO_TABLE Convert a discrete CPD to a table Daniel@0: % T = convert_to_table(CPD, domain, evidence) Daniel@0: % Daniel@0: % We convert the CPD to a CPT, and then lookup the evidence on the discrete parents. Daniel@0: % The resulting table can easily be converted to a potential. Daniel@0: Daniel@0: domain = domain(:); Daniel@0: CPT = CPD_to_CPT(CPD); Daniel@0: odom = domain(~isemptycell(evidence(domain))); Daniel@0: vals = cat(1, evidence{odom}); Daniel@0: map = find_equiv_posns(odom, domain); Daniel@0: index = mk_multi_index(length(domain), map, vals); Daniel@0: T = CPT(index{:}); Daniel@0: T = T(:);