Daniel@0: function CPD = learn_params(CPD, fam, data, ns, cnodes) Daniel@0: %function CPD = learn_params(CPD, local_data) Daniel@0: % LEARN_PARAMS Compute the ML/MAP estimate of the params of a tabular CPD given complete data Daniel@0: % CPD = learn_params(CPD, local_data) Daniel@0: % Daniel@0: % local_data(i,m) is the value of i'th family member in case m (can be cell array). Daniel@0: Daniel@0: local_data = data(fam, :); Daniel@0: if iscell(local_data) Daniel@0: local_data = cell2num(local_data); Daniel@0: end Daniel@0: counts = compute_counts(local_data, CPD.sizes); Daniel@0: switch CPD.prior_type Daniel@0: case 'none', CPD.CPT = mk_stochastic(counts); Daniel@0: case 'dirichlet', CPD.CPT = mk_stochastic(counts + CPD.dirichlet); Daniel@0: otherwise, error(['unrecognized prior ' CPD.prior_type]) Daniel@0: end