Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/CPDs/@tabular_CPD/Old/BIC_score_CPD.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
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 |