Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/CPDs/@generic_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 % LEARN_PARAMS Compute the maximum likelihood estimate of the params of a generic CPD given complete data | |
3 % CPD = learn_params(CPD, fam, data, ns, cnodes) | |
4 % | |
5 % data(i,m) is the value of node i in case m (can be cell array). | |
6 % We assume this node has a maximize_params method. | |
7 | |
8 %error('no longer supported') % KPM 1 Feb 03 | |
9 | |
10 if 1 | |
11 ncases = size(data, 2); | |
12 CPD = reset_ess(CPD); | |
13 % make a fully observed joint distribution over the family | |
14 fmarginal.domain = fam; | |
15 fmarginal.T = 1; | |
16 fmarginal.mu = []; | |
17 fmarginal.Sigma = []; | |
18 if ~iscell(data) | |
19 cases = num2cell(data); | |
20 else | |
21 cases = data; | |
22 end | |
23 hidden_bitv = zeros(1, max(fam)); | |
24 for m=1:ncases | |
25 % specify (as a bit vector) which elements in the family domain are hidden | |
26 hidden_bitv = zeros(1, max(fmarginal.domain)); | |
27 ev = cases(:,m); | |
28 hidden_bitv(find(isempty(evidence)))=1; | |
29 CPD = update_ess(CPD, fmarginal, ev, ns, cnodes, hidden_bitv); | |
30 end | |
31 CPD = maximize_params(CPD); | |
32 end |