about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/BNT/CPDs/@discrete_CPD/convert_CPD_to_table_hidden_ps.m
blob: c8f44f7e9ad9a72bd1bd81eb20fe56a5e0cb3539 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function T = convert_CPD_to_table_hidden_ps(CPD, child_obs)
% CONVERT_CPD_TO_TABLE_HIDDEN_PS Convert a discrete CPD to a table
% T = convert_CPD_to_table_hidden_ps(CPD, child_obs)
%
% This is like convert_to_table, except that we are guaranteed that
% none of the parents have evidence on them.
% child_obs may be an integer (1,2,...) or [].

CPT = CPD_to_CPT(CPD);
if isempty(child_obs)
  T = CPT(:);
else
  sz = dom_sizes(CPD);
  if length(sz)==1 % no parents
    T = CPT(child_obs);
  else
    CPT = reshape(CPT, prod(sz(1:end-1)), sz(end));
    T = CPT(:, child_obs);
  end
end