bic_score_family.m
来自「麻省理工学院的人工智能工具箱,很珍贵,希望对大家有用!」· M 代码 · 共 24 行
M
24 行
function [S, LL] = bic_score(counts, CPT, ncases)% BIC_SCORE Bayesian Information Criterion score for a single family% [S, LL] = bic_score(counts, CPT, ncases)%% S is a large sample approximation to the log marginal likelihood,% which can be computed using dirichlet_score.%% S = \log [ prod_j _prod_k theta_ijk ^ N_ijk ] - 0.5*d*log(ncases) % where counts encode N_ijk, theta_ijk is the MLE comptued from counts,% and d is the num of free parameters.%CPT = mk_stochastic(counts);tiny = exp(-700);LL = sum(log(CPT(:) + tiny) .* counts(:));% CPT(i) = 0 iff counts(i) = 0 so it is okay to add tinyns = mysize(counts);ns_ps = ns(1:end-1);ns_self = ns(end);nparams = prod([ns_ps (ns_self-1)]);% sum-to-1 constraint reduces the effective num. vals of the node by 1S = LL - 0.5*nparams*log(ncases);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?