Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/CPDs/@gaussian_CPD/convert_to_table.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 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 |