comparison toolboxes/FullBNT-1.0.7/bnt/CPDs/@tabular_kernel/convert_to_pot.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function pot = convert_to_pot(CPD, pot_type, domain, evidence)
2 % CONVERT_TO_POT Convert a tabular CPD to one or more potentials
3 % pot = convert_to_pot(CPD, pot_type, domain, evidence)
4
5 % This is the same as discrete_CPD/convert_to_pot,
6 % except we didn't want to the kernel to inherit methods like sample_node etc.
7
8 sz = CPD.sz;
9 ns = zeros(1, max(domain));
10 ns(domain) = sz;
11
12 odom = domain(~isemptycell(evidence(domain)));
13 T = convert_to_table(CPD, domain, evidence);
14
15 switch pot_type
16 case 'u',
17 pot = upot(domain, sz, T, 0*myones(sz));
18 case 'd',
19 ns(odom) = 1;
20 pot = dpot(domain, ns(domain), T);
21 case 'c',
22 % Since we want the output to be a Gaussian, the whole family must be observed.
23 % In other words, the potential is really just a constant.
24 p = T.p;
25 %p = prob_node(CPD, evidence(domain(end)), evidence(domain(1:end-1)));
26 ns(domain) = 0;
27 pot = cpot(domain, ns(domain), log(p));
28 case 'cg',
29 T = T(:);
30 ns(odom) = 1;
31 can = cell(1, length(T));
32 for i=1:length(T)
33 can{i} = cpot([], [], log(T(i)));
34 end
35 pot = cgpot(domain, [], ns, can);
36 end
37