Mercurial > hg > camir-aes2014
annotate 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 |
rev | line source |
---|---|
wolffd@0 | 1 function T = convert_to_table(CPD, domain, evidence) |
wolffd@0 | 2 % CONVERT_TO_TABLE Convert a Gaussian CPD to a table |
wolffd@0 | 3 % T = convert_to_table(CPD, domain, evidence) |
wolffd@0 | 4 |
wolffd@0 | 5 |
wolffd@0 | 6 sz = CPD.sizes; |
wolffd@0 | 7 ns = zeros(1, max(domain)); |
wolffd@0 | 8 ns(domain) = sz; |
wolffd@0 | 9 |
wolffd@0 | 10 odom = domain(~isemptycell(evidence(domain))); |
wolffd@0 | 11 ps = domain(1:end-1); |
wolffd@0 | 12 cps = ps(CPD.cps); |
wolffd@0 | 13 dps = ps(CPD.dps); |
wolffd@0 | 14 self = domain(end); |
wolffd@0 | 15 cdom = [cps(:)' self]; |
wolffd@0 | 16 ddom = dps; |
wolffd@0 | 17 cnodes = cdom; |
wolffd@0 | 18 |
wolffd@0 | 19 [m, C, W] = gaussian_CPD_params_given_dps(CPD, domain, evidence); |
wolffd@0 | 20 |
wolffd@0 | 21 |
wolffd@0 | 22 ns(odom) = 1; |
wolffd@0 | 23 dpsize = prod(ns(dps)); |
wolffd@0 | 24 self = domain(end); |
wolffd@0 | 25 assert(myismember(self, odom)); |
wolffd@0 | 26 self_val = evidence{self}; |
wolffd@0 | 27 T = zeros(dpsize, 1); |
wolffd@0 | 28 if length(cps) > 0 |
wolffd@0 | 29 assert(~any(isemptycell(evidence(cps)))); |
wolffd@0 | 30 cps_vals = cat(1, evidence{cps}); |
wolffd@0 | 31 for i=1:dpsize |
wolffd@0 | 32 T(i) = gaussian_prob(self_val, m(:,i) + W(:,:,i)*cps_vals, C(:,:,i)); |
wolffd@0 | 33 end |
wolffd@0 | 34 else |
wolffd@0 | 35 for i=1:dpsize |
wolffd@0 | 36 T(i) = gaussian_prob(self_val, m(:,i), C(:,:,i)); |
wolffd@0 | 37 end |
wolffd@0 | 38 end |