To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / _FullBNT / BNT / CPDs / @discrete_CPD / convert_CPD_to_table_hidden_ps.m @ 8:b5b38998ef3b

History | View | Annotate | Download (582 Bytes)

1
function T = convert_CPD_to_table_hidden_ps(CPD, child_obs)
2
% CONVERT_CPD_TO_TABLE_HIDDEN_PS Convert a discrete CPD to a table
3
% T = convert_CPD_to_table_hidden_ps(CPD, child_obs)
4
%
5
% This is like convert_to_table, except that we are guaranteed that
6
% none of the parents have evidence on them.
7
% child_obs may be an integer (1,2,...) or [].
8

    
9
CPT = CPD_to_CPT(CPD);
10
if isempty(child_obs)
11
  T = CPT(:);
12
else
13
  sz = dom_sizes(CPD);
14
  if length(sz)==1 % no parents
15
    T = CPT(child_obs);
16
  else
17
    CPT = reshape(CPT, prod(sz(1:end-1)), sz(end));
18
    T = CPT(:, child_obs);
19
  end
20
end