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 / @root_CPD / convert_to_pot.m @ 8:b5b38998ef3b

History | View | Annotate | Download (685 Bytes)

1
function pot = convert_to_pot(CPD, pot_type, domain, evidence)
2
% CONVERT_TO_POT Convert a root CPD to one or more potentials
3
% pots = convert_to_pot(CPD, pot_type, domain, evidence)
4

    
5
assert(length(domain)==1);
6
assert(~isempty(evidence(domain)));
7
T = 1;   
8

    
9
sz = CPD.sizes;
10
ns = zeros(1, max(domain));
11
ns(domain) = sz;
12

    
13
switch pot_type
14
 case 'u',
15
  pot = upot(domain, 1, T, 0);
16
 case 'd',
17
  ns(domain) = 1;
18
  pot = dpot(domain, ns(domain), T);          
19
 case {'c','g'},
20
  ns(domain) = 0;
21
  pot = cpot(domain, ns(domain), 0);
22
 case 'cg',
23
  ddom = [];
24
  cdom = domain; % we assume the root node is cts
25
  %pot = cgpot(ddom, cdom, ns, {cpot([],[],0)});
26
  pot = cgpot(ddom, cdom, ns);
27
end
28