comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:cc4b1211e677
1 function CPD = learn_params(CPD, fam, data, ns, cnodes)
2 %function CPD = learn_params(CPD, local_data)
3 % LEARN_PARAMS Compute the ML/MAP estimate of the params of a tabular CPD given complete data
4 % CPD = learn_params(CPD, local_data)
5 %
6 % local_data(i,m) is the value of i'th family member in case m (can be cell array).
7
8 local_data = data(fam, :);
9 if iscell(local_data)
10 local_data = cell2num(local_data);
11 end
12 counts = compute_counts(local_data, CPD.sizes);
13 switch CPD.prior_type
14 case 'none', CPD.CPT = mk_stochastic(counts);
15 case 'dirichlet', CPD.CPT = mk_stochastic(counts + CPD.dirichlet);
16 otherwise, error(['unrecognized prior ' CPD.prior_type])
17 end