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 / Old / BIC_score_CPD.m @ 8:b5b38998ef3b

History | View | Annotate | Download (503 Bytes)

1
function score = BIC_score_CPD(CPD, fam, data, ns, cnodes)
2
% BIC_score_CPD Compute the BIC score of a tabular CPD
3
% score = BIC_score_CPD(CPD, fam, data, ns, cnodes)
4

    
5
if iscell(data)
6
  local_data = cell2num(data(fam,:));
7
else
8
  local_data = data(fam, :);
9
end
10
counts = compute_counts(local_data, CPD.sizes);
11
CPT = mk_stochastic(counts); % MLE
12
tiny = exp(-700); 
13
CPT = CPT + (CPT==0)*tiny;  % replace 0s by tiny
14
LL = sum(log(CPT(:)) .* counts(:));
15
N = size(data, 2);
16
score = LL - 0.5*CPD.nparams*log(N);
17