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