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

History | View | Annotate | Download (711 Bytes)

1
function score = BIC_score_CPD(CPD, fam, data, ns, cnodes)
2
% BIC_score_CPD Compute the BIC score of a generic CPD
3
% score = BIC_score_CPD(CPD, fam, data, ns, cnodes)
4
%
5
% We assume this node has a maximize_params method
6

    
7
ncases = size(data, 2);
8
CPD = reset_ess(CPD);
9
% make a fully observed joint distribution over the family
10
fmarginal.domain = fam;
11
fmarginal.T = 1;
12
fmarginal.mu = [];
13
fmarginal.Sigma = [];
14
if ~iscell(data)
15
  cases = num2cell(data);
16
else
17
  cases = data;
18
end
19
for m=1:ncases
20
  CPD = update_ess(CPD, fmarginal, cases(:,m), ns, cnodes);
21
end
22
CPD = maximize_params(CPD);
23
self = fam(end);
24
ps = fam(1:end-1);
25
L = log_prob_node(CPD, cases(self,:), cases(ps,:));
26
score = L - 0.5*CPD.nparams*log(ncases);