Daniel@0: function L = log_prob_node(CPD, self_ev, pev) Daniel@0: % LOG_PROB_NODE Compute sum_m log P(x(i,m)| x(pi_i,m), theta_i) for node i (discrete) Daniel@0: % L = log_prob_node(CPD, self_ev, pev) Daniel@0: % Daniel@0: % self_ev(m) is the evidence on this node in case m. Daniel@0: % pev(i,m) is the evidence on the i'th parent in case m (if there are any parents). Daniel@0: % (These may also be cell arrays.) Daniel@0: Daniel@0: [P, p] = prob_node(CPD, self_ev, pev); % P may underflow, so we use p Daniel@0: tiny = exp(-700); Daniel@0: p = p + (p==0)*tiny; % replace 0s by tiny Daniel@0: L = sum(log(p));