annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@gaussian_CPD/CPD_to_pi.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 pi = CPD_to_pi(CPD, msg_type, n, ps, msg, evidence)
wolffd@0 2 % CPD_TO_PI Compute the pi vector (gaussian)
wolffd@0 3 % function pi = CPD_to_pi(CPD, msg_type, n, ps, msg, evidence)
wolffd@0 4
wolffd@0 5 switch msg_type
wolffd@0 6 case 'd',
wolffd@0 7 error('gaussian_CPD can''t create discrete msgs')
wolffd@0 8 case 'g',
wolffd@0 9 [m, Q, W] = gaussian_CPD_params_given_dps(CPD, [ps n], evidence);
wolffd@0 10 cps = ps(CPD.cps);
wolffd@0 11 cpsizes = CPD.sizes(CPD.cps);
wolffd@0 12 pi.mu = m;
wolffd@0 13 pi.Sigma = Q;
wolffd@0 14 for k=1:length(cps) % only get pi msgs from cts parents
wolffd@0 15 %bk = block(k, cpsizes);
wolffd@0 16 bk = CPD.cps_block_ndx{k};
wolffd@0 17 Bk = W(:, bk);
wolffd@0 18 m = msg{n}.pi_from_parent{k};
wolffd@0 19 pi.Sigma = pi.Sigma + Bk * m.Sigma * Bk';
wolffd@0 20 pi.mu = pi.mu + Bk * m.mu; % m.mu = u(k)
wolffd@0 21 end
wolffd@0 22 end