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 / @noisyor_CPD / private / sum_prod_CPD_and_pi_msgs.m @ 8:b5b38998ef3b
History | View | Annotate | Download (837 Bytes)
| 1 |
function pi = sum_prod_CPD_and_pi_msgs(CPD, n, ps, msg, except) |
|---|---|
| 2 |
% SUM_PROD_CPD_AND_PI_MSGS Compute pi = sum_{u\p} P(n|u) prod_{ui in ps\p} pi_msg(ui->n)
|
| 3 |
% pi = sum_prod_CPD_and_pi_msgs(CPD, n, ps, msg, p) |
| 4 |
% |
| 5 |
% pi = prod_i (qi pi_msg(ui->n) + 1 - pi_msg(ui->n)) = prod_i (1 - ci pi_msg(ui->n)) |
| 6 |
% is the product of the endorsement withheld (Pearl p188 eqn 4.56) |
| 7 |
% We skip p from this product, if specified. |
| 8 |
|
| 9 |
if nargin < 5, except = -1; end |
| 10 |
pi = 1; |
| 11 |
for i=1:length(ps) |
| 12 |
p = ps(i); |
| 13 |
if p ~= except |
| 14 |
pi_from_parent = msg{n}.pi_from_parent{i};
|
| 15 |
q = CPD.inhibit(i); |
| 16 |
c = 1-q; |
| 17 |
pi = pi * (1 - c*pi_from_parent(2)); |
| 18 |
end |
| 19 |
end |
| 20 |
% The pi msg that a leak node sends to its child is [0 1] |
| 21 |
% since its own pi is [0 1] and its lambda to self is [0 1]. |
| 22 |
q = CPD.leak_inhibit; |
| 23 |
% 1 - c*pi_from_parent = 1-c*1 = q |
| 24 |
pi = pi * q; |
| 25 |
|