⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prob_cpd.m

📁 贝叶斯网络的matlab实现。可以创建贝叶斯网络、训练模型
💻 M
字号:
function p = prob_CPD(CPD, domain, ns, cnodes, evidence)
% PROB_CPD Compute prob of a node given evidence on the parents (discrete)
% p = prob_CPD(CPD, domain, ns, cnodes, evidence)
%
% domain is the domain of CPD.
% node_sizes(i) is the size of node i.
% cnodes = all the cts nodes
% evidence{i} is the evidence on the i'th node.

ps = domain(1:end-1);
self = domain(end);
CPT = CPD_to_CPT(CPD);

if isempty(ps)
  T = CPT;
else
  assert(~any(isemptycell(evidence(ps))));
  pvals = cat(1, evidence{ps});
  i = subv2ind(ns(ps), pvals(:)');
  T = reshape(CPT, [prod(ns(ps)) ns(self)]);
  T = T(i,:);
end
p = T(evidence{self});

 

⌨️ 快捷键说明

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