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