To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / _FullBNT / BNT / CPDs / @generic_CPD / learn_params.m @ 8:b5b38998ef3b

History | View | Annotate | Download (975 Bytes)

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