annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@tabular_CPD/learn_params.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function CPD = learn_params(CPD, fam, data, ns, cnodes)
Daniel@0 2 %function CPD = learn_params(CPD, local_data)
Daniel@0 3 % LEARN_PARAMS Compute the ML/MAP estimate of the params of a tabular CPD given complete data
Daniel@0 4 % CPD = learn_params(CPD, local_data)
Daniel@0 5 %
Daniel@0 6 % local_data(i,m) is the value of i'th family member in case m (can be cell array).
Daniel@0 7
Daniel@0 8 local_data = data(fam, :);
Daniel@0 9 if iscell(local_data)
Daniel@0 10 local_data = cell2num(local_data);
Daniel@0 11 end
Daniel@0 12 counts = compute_counts(local_data, CPD.sizes);
Daniel@0 13 switch CPD.prior_type
Daniel@0 14 case 'none', CPD.CPT = mk_stochastic(counts);
Daniel@0 15 case 'dirichlet', CPD.CPT = mk_stochastic(counts + CPD.dirichlet);
Daniel@0 16 otherwise, error(['unrecognized prior ' CPD.prior_type])
Daniel@0 17 end