annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@discrete_CPD/convert_CPD_to_table_hidden_ps.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_CPD_to_table_hidden_ps(CPD, child_obs)
wolffd@0 2 % CONVERT_CPD_TO_TABLE_HIDDEN_PS Convert a discrete CPD to a table
wolffd@0 3 % T = convert_CPD_to_table_hidden_ps(CPD, child_obs)
wolffd@0 4 %
wolffd@0 5 % This is like convert_to_table, except that we are guaranteed that
wolffd@0 6 % none of the parents have evidence on them.
wolffd@0 7 % child_obs may be an integer (1,2,...) or [].
wolffd@0 8
wolffd@0 9 CPT = CPD_to_CPT(CPD);
wolffd@0 10 if isempty(child_obs)
wolffd@0 11 T = CPT(:);
wolffd@0 12 else
wolffd@0 13 sz = dom_sizes(CPD);
wolffd@0 14 if length(sz)==1 % no parents
wolffd@0 15 T = CPT(child_obs);
wolffd@0 16 else
wolffd@0 17 CPT = reshape(CPT, prod(sz(1:end-1)), sz(end));
wolffd@0 18 T = CPT(:, child_obs);
wolffd@0 19 end
wolffd@0 20 end