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 / @tabular_CPD / Old / log_marg_prob_node_case.m @ 8:b5b38998ef3b

History | View | Annotate | Download (711 Bytes)

1
function L = log_marg_prob_node_case(CPD, y, x)
2
% LOG_MARG_PROB_NODE_CASE Compute prod_m log P(x(i,m)| x(pi_i,m)) for node i (tabular)
3
% L = log_marg_prob_node_case(CPD, self_ev, parent_ev)
4
% 
5
% This is a slightly optimised version of log_marg_prob_node.
6
% We assume we have exactly 1 case, i.e., y is a scalar and x is a vector (not a cell array).
7

    
8
sz = CPD.sizes;
9
nparents = length(sz)-1;
10

    
11
% We assume the CPTs are already set to the mean of the posterior (due to update_params)
12

    
13
switch nparents
14
 case 0, p = CPD.CPT(y);
15
 case 1, p = CPD.CPT(x(1), y);
16
 case 2, p = CPD.CPT(x(1), x(2), y);
17
 case 3, p = CPD.CPT(x(1), x(2), x(3), y);
18
 otherwise,
19
  ind = subv2ind(sz, [x y]);
20
  p = CPD.CPT(ind);
21
end
22
L = log(p);