linear_gaussian_to_cpot.m

来自「Bayes网络工具箱」· M 代码 · 共 41 行

M
41
字号
function pot = linear_gaussian_to_cpot(mu, Sigma, W, domain, ns, cnodes, evidence)% LINEAR_GAUSSIAN_TO_CPOT Convert a linear Gaussian CPD  to a canonical potential.% pot = linear_gaussian_to_cpot(mu, Sigma, W, domain, ns, cnodes, evidence)odom = domain(~isemptycell(evidence(domain)));hdom = domain(isemptycell(evidence(domain)));cobs = myintersect(cnodes, odom);chid = myintersect(cnodes, hdom);cvals = cat(1, evidence{cobs});%[g,h,K] = gaussian_to_canonical(mu, Sigma, W);Sinv = inv(Sigma);g = -0.5*mu'*Sinv*mu + log(normal_coef(Sigma));if size(W,2)==0  % no cts parents  h = Sinv*mu;  K = Sinv;else  h = [-W'*Sinv*mu; Sinv*mu];  K = [W'*Sinv*W  -W'*Sinv';       -Sinv*W     Sinv]; endif ~isempty(cvals)  %[g, h, K] = enter_evidence_canonical(g, h, K, chid, cobs, cvals(:), ns);    [hx, hy, KXX, KXY, KYX, KYY] = partition_matrix_vec(h, K, chid, cobs, ns);  y = cvals(:);  g = g + hy'*y - 0.5*y'*KYY*y;  if length(hx)==0 % isempty(X) % i.e., we have instantiated everything away    h = [];    K = [];  else    h = hx - KXY*y;    K = KXX;  endendns(odom) = 0;pot = cpot(domain, ns(domain), g, h, K);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?