To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / _FullBNT / BNT / CPDs / @gaussian_CPD / CPD_to_pi.m @ 8:b5b38998ef3b
History | View | Annotate | Download (705 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 |
[m, Q, W] = gaussian_CPD_params_given_dps(CPD, [ps n], evidence); |
| 10 |
cps = ps(CPD.cps); |
| 11 |
cpsizes = CPD.sizes(CPD.cps); |
| 12 |
pi.mu = m; |
| 13 |
pi.Sigma = Q; |
| 14 |
for k=1:length(cps) % only get pi msgs from cts parents |
| 15 |
%bk = block(k, cpsizes); |
| 16 |
bk = CPD.cps_block_ndx{k};
|
| 17 |
Bk = W(:, bk); |
| 18 |
m = msg{n}.pi_from_parent{k};
|
| 19 |
pi.Sigma = pi.Sigma + Bk * m.Sigma * Bk'; |
| 20 |
pi.mu = pi.mu + Bk * m.mu; % m.mu = u(k) |
| 21 |
end |
| 22 |
end |