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 / @gaussian_CPD / convert_to_table.m @ 8:b5b38998ef3b

History | View | Annotate | Download (884 Bytes)

1
function T = convert_to_table(CPD, domain, evidence)
2
% CONVERT_TO_TABLE Convert a Gaussian CPD to a table
3
% T = convert_to_table(CPD, domain, evidence)
4

    
5

    
6
sz = CPD.sizes;
7
ns = zeros(1, max(domain));
8
ns(domain) = sz;
9

    
10
odom = domain(~isemptycell(evidence(domain)));
11
ps = domain(1:end-1);
12
cps = ps(CPD.cps);
13
dps = ps(CPD.dps);
14
self = domain(end);
15
cdom = [cps(:)' self];
16
ddom = dps;
17
cnodes = cdom;
18

    
19
[m, C, W] = gaussian_CPD_params_given_dps(CPD, domain, evidence);
20

    
21

    
22
ns(odom) = 1;
23
dpsize = prod(ns(dps));
24
self = domain(end);
25
assert(myismember(self, odom));
26
self_val = evidence{self};
27
T = zeros(dpsize, 1);
28
if length(cps) > 0 
29
  assert(~any(isemptycell(evidence(cps))));
30
  cps_vals = cat(1, evidence{cps});
31
  for i=1:dpsize
32
    T(i) = gaussian_prob(self_val, m(:,i) + W(:,:,i)*cps_vals, C(:,:,i));
33
  end
34
else
35
  for i=1:dpsize
36
    T(i) = gaussian_prob(self_val, m(:,i), C(:,:,i));
37
  end
38
end