Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/inference/static/@pearl_inf_engine/private/compute_bel.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function bel = compute_bel(msg_type, pi, lambda) | |
2 | |
3 switch msg_type, | |
4 case 'd', bel = normalise(pi .* lambda); | |
5 case 'g', | |
6 if isinf(lambda.precision) % ignore pi because lambda is completely certain (observed) | |
7 bel.mu = lambda.mu; | |
8 bel.Sigma = zeros(length(bel.mu)); % infinite precision => 0 variance | |
9 elseif all(pi.Sigma==0) % ignore lambda because pi is completely certain (delta fn prior) | |
10 bel.Sigma = pi.Sigma; | |
11 bel.mu = pi.mu; | |
12 elseif all(isinf(pi.Sigma)) % ignore pi because pi is completely uncertain | |
13 bel.Sigma = inv(lambda.precision); | |
14 bel.mu = bel.Sigma * lambda.info_state; | |
15 elseif all(lambda.precision == 0) % ignore lambda because lambda is completely uncertain | |
16 bel.Sigma = pi.Sigma; | |
17 bel.mu = pi.mu; | |
18 else % combine both pi and lambda | |
19 pi_precision = inv(pi.Sigma); | |
20 bel.Sigma = inv(pi_precision + lambda.precision); | |
21 bel.mu = bel.Sigma*(pi_precision * pi.mu + lambda.info_state); | |
22 end | |
23 otherwise, error(['unrecognized msg type ' msg_type]) | |
24 end |