annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@gmux_CPD/CPD_to_pi.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function pi = CPD_to_pi(CPD, msg_type, n, ps, msg, evidence)
Daniel@0 2 % CPD_TO_PI Compute the pi vector (gaussian)
Daniel@0 3 % function pi = CPD_to_pi(CPD, msg_type, n, ps, msg, evidence)
Daniel@0 4
Daniel@0 5 switch msg_type
Daniel@0 6 case 'd',
Daniel@0 7 error('gaussian_CPD can''t create discrete msgs')
Daniel@0 8 case 'g',
Daniel@0 9 dps = ps(CPD.dps);
Daniel@0 10 k = evidence{dps};
Daniel@0 11 if isempty(k)
Daniel@0 12 error('gmux node must have observed discrete parent')
Daniel@0 13 end
Daniel@0 14 m = msg{n}.pi_from_parent{k};
Daniel@0 15 B = CPD.weights(:,:,k);
Daniel@0 16 pi.mu = CPD.mean(:,k) + B * m.mu;
Daniel@0 17 pi.Sigma = CPD.cov(:,:,k) + B * m.Sigma * B';
Daniel@0 18 end