comparison toolboxes/FullBNT-1.0.7/bnt/CPDs/@tabular_CPD/learn_params.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
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