annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@tabular_CPD/Old/log_marg_prob_node_case.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function L = log_marg_prob_node_case(CPD, y, x)
wolffd@0 2 % LOG_MARG_PROB_NODE_CASE Compute prod_m log P(x(i,m)| x(pi_i,m)) for node i (tabular)
wolffd@0 3 % L = log_marg_prob_node_case(CPD, self_ev, parent_ev)
wolffd@0 4 %
wolffd@0 5 % This is a slightly optimised version of log_marg_prob_node.
wolffd@0 6 % We assume we have exactly 1 case, i.e., y is a scalar and x is a vector (not a cell array).
wolffd@0 7
wolffd@0 8 sz = CPD.sizes;
wolffd@0 9 nparents = length(sz)-1;
wolffd@0 10
wolffd@0 11 % We assume the CPTs are already set to the mean of the posterior (due to update_params)
wolffd@0 12
wolffd@0 13 switch nparents
wolffd@0 14 case 0, p = CPD.CPT(y);
wolffd@0 15 case 1, p = CPD.CPT(x(1), y);
wolffd@0 16 case 2, p = CPD.CPT(x(1), x(2), y);
wolffd@0 17 case 3, p = CPD.CPT(x(1), x(2), x(3), y);
wolffd@0 18 otherwise,
wolffd@0 19 ind = subv2ind(sz, [x y]);
wolffd@0 20 p = CPD.CPT(ind);
wolffd@0 21 end
wolffd@0 22 L = log(p);