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 / @tabular_CPD / learn_params.m @ 8:b5b38998ef3b

History | View | Annotate | Download (661 Bytes)

1
function CPD = learn_params(CPD, fam, data, ns, cnodes)
2
%function CPD = learn_params(CPD, local_data)
3
% LEARN_PARAMS Compute the ML/MAP estimate of the params of a tabular CPD given complete data
4
% CPD = learn_params(CPD, local_data)
5
%
6
% local_data(i,m) is the value of i'th family member in case m (can be cell array).
7

    
8
local_data = data(fam, :); 
9
if iscell(local_data)
10
  local_data = cell2num(local_data);
11
end
12
counts = compute_counts(local_data, CPD.sizes);
13
switch CPD.prior_type
14
 case 'none', CPD.CPT = mk_stochastic(counts); 
15
 case 'dirichlet', CPD.CPT = mk_stochastic(counts + CPD.dirichlet); 
16
 otherwise, error(['unrecognized prior ' CPD.prior_type])
17
end