Mercurial > hg > camir-aes2014
annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@discrete_CPD/convert_to_table.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 T = convert_to_table(CPD, domain, evidence) |
wolffd@0 | 2 % CONVERT_TO_TABLE Convert a discrete CPD to a table |
wolffd@0 | 3 % T = convert_to_table(CPD, domain, evidence) |
wolffd@0 | 4 % |
wolffd@0 | 5 % We convert the CPD to a CPT, and then lookup the evidence on the discrete parents. |
wolffd@0 | 6 % The resulting table can easily be converted to a potential. |
wolffd@0 | 7 |
wolffd@0 | 8 domain = domain(:); |
wolffd@0 | 9 CPT = CPD_to_CPT(CPD); |
wolffd@0 | 10 odom = domain(~isemptycell(evidence(domain))); |
wolffd@0 | 11 vals = cat(1, evidence{odom}); |
wolffd@0 | 12 map = find_equiv_posns(odom, domain); |
wolffd@0 | 13 index = mk_multi_index(length(domain), map, vals); |
wolffd@0 | 14 T = CPT(index{:}); |
wolffd@0 | 15 T = T(:); |