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