annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@tabular_kernel/convert_to_table.m @ 0:cc4b1211e677
tip
initial commit to HG from
Changeset:
646 (e263d8a21543) added further path and more save "camirversion.m"
author |
Daniel Wolff |
date |
Fri, 19 Aug 2016 13:07:06 +0200 |
parents |
|
children |
|
rev |
line source |
Daniel@0
|
1 function T = convert_to_table(CPD, domain, evidence)
|
Daniel@0
|
2 % CONVERT_TO_TABLE Convert a discrete CPD to a table
|
Daniel@0
|
3 % T = convert_to_table(CPD, domain, evidence)
|
Daniel@0
|
4 %
|
Daniel@0
|
5 % We convert the CPD to a CPT, and then lookup the evidence on the discrete parents.
|
Daniel@0
|
6 % The resulting table can easily be converted to a potential.
|
Daniel@0
|
7
|
Daniel@0
|
8 CPT = CPD.table;
|
Daniel@0
|
9 odom = domain(~isemptycell(evidence(domain)));
|
Daniel@0
|
10 vals = cat(1, evidence{odom});
|
Daniel@0
|
11 map = find_equiv_posns(odom, domain);
|
Daniel@0
|
12 index = mk_multi_index(length(domain), map, vals);
|
Daniel@0
|
13 T = CPT(index{:});
|