wolffd@0: function pi = CPD_to_pi(CPD, msg_type, n, ps, msg, evidence) wolffd@0: % CPD_TO_PI Compute the pi vector (gaussian) wolffd@0: % function pi = CPD_to_pi(CPD, msg_type, n, ps, msg, evidence) wolffd@0: wolffd@0: switch msg_type wolffd@0: case 'd', wolffd@0: error('gaussian_CPD can''t create discrete msgs') wolffd@0: case 'g', wolffd@0: [m, Q, W] = gaussian_CPD_params_given_dps(CPD, [ps n], evidence); wolffd@0: cps = ps(CPD.cps); wolffd@0: cpsizes = CPD.sizes(CPD.cps); wolffd@0: pi.mu = m; wolffd@0: pi.Sigma = Q; wolffd@0: for k=1:length(cps) % only get pi msgs from cts parents wolffd@0: %bk = block(k, cpsizes); wolffd@0: bk = CPD.cps_block_ndx{k}; wolffd@0: Bk = W(:, bk); wolffd@0: m = msg{n}.pi_from_parent{k}; wolffd@0: pi.Sigma = pi.Sigma + Bk * m.Sigma * Bk'; wolffd@0: pi.mu = pi.mu + Bk * m.mu; % m.mu = u(k) wolffd@0: end wolffd@0: end