matthiasm@8: function y = sample_node(CPD, pvals) matthiasm@8: % SAMPLE_NODE Draw a random sample from P(Xi | x(pi_i), theta_i) (discrete) matthiasm@8: % y = sample_node(CPD, parent_evidence) matthiasm@8: % matthiasm@8: % parent_evidence{i} is the value of the i'th parent matthiasm@8: matthiasm@8: n = length(pvals)+1; matthiasm@8: dom = 1:n; matthiasm@8: %evidence = cell(1,n); matthiasm@8: %evidence(1:n-1) = pvals(:)'; matthiasm@8: evidence = pvals; matthiasm@8: evidence{end+1} = []; matthiasm@8: T = convert_to_table(CPD, dom, evidence); matthiasm@8: y = sample_discrete(T);