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