To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / _FullBNT / BNT / CPDs / @gmux_CPD / CPD_to_pi.m @ 8:b5b38998ef3b

History | View | Annotate | Download (547 Bytes)

1
function pi = CPD_to_pi(CPD, msg_type, n, ps, msg, evidence)
2
% CPD_TO_PI Compute the pi vector (gaussian)
3
% function pi = CPD_to_pi(CPD, msg_type, n, ps, msg, evidence)
4

    
5
switch msg_type
6
 case 'd',
7
  error('gaussian_CPD can''t create discrete msgs')
8
 case 'g',
9
  dps = ps(CPD.dps);
10
  k = evidence{dps};
11
  if isempty(k)
12
    error('gmux node must have observed discrete parent')
13
  end
14
  m = msg{n}.pi_from_parent{k}; 
15
  B = CPD.weights(:,:,k);
16
  pi.mu = CPD.mean(:,k) + B * m.mu;
17
  pi.Sigma = CPD.cov(:,:,k) + B * m.Sigma * B';
18
end