enter_soft_evidence.m

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

M
50
字号
function [clpot, loglik] = enter_soft_evidence(engine, CPDpot, observed, filter)% ENTER_SOFT_EVIDENCE Add the specified evidence to the network (jtree_dbn_fast)% [clpot, loglik] = enter_soft_evidence(engine, CPDpot, observed, filter)assert(filter == 0); % this code is designed for smoothing[ss T] = size(CPDpot);  % Forwardsalpha = cell(1,T);t = 1;[alpha{t}, logscale(t)] = enter_soft_evidence(engine.sub_engine1, engine.fwd1.clq_ass_to_node, ...					   CPDpot(:,1), engine.fwd1.CPD_ndx);clqs = [engine.fwd.clq_ass_to_cluster(:,1); engine.fwd.clq_ass_to_node(:,2)];ndx = [engine.fwd.cluster_ndx(:,1); engine.fwd.CPD_ndx(:,2)];for t=2:T  pots = [alpha(:,t-1); CPDpot(:,t)];  [alpha{t}, logscale(t)] = enter_soft_evidence(engine.fwd.engine, clqs, pots, ndx);endloglik = sum(logscale);% Backwardsbeta = cell(1,T);t = T;bnet = bnet_from_engine(engine);ns = bnet.node_sizes(:);ns(find(observed(:,t-1:t))) = 1;dom = (1:ss) + ss;beta{t} = myones(ns(dom));clqs = [engine.back.clq_ass_to_cluster(:,2); engine.back.clq_ass_to_node(:,2)];ndx = [engine.back.cluster_ndx(:,2); engine.back.CPD_ndx(:,2)];for t=T-1:-1:1  pots = [beta(:,t+1); CPDpot(:,t+1)];  beta{t} = enter_soft_evidence(engine.back.engine, clqs, pots, ndx);end% CombineQ = length(cliques_from_engine(engine.sub_engine));clpot = cell(Q,T); % clpot{t} contains evidence from slices t-1, t for t > 1clqs = [engine.fb.clq_ass_to_cluster(:); engine.fb.clq_ass_to_node(:,2)];ndx = [engine.fb.cluster_ndx(:); engine.fb.CPD_ndx(:,2)];for t=1:T-1  pots = [alpha(:,t); beta(:,t+1); CPDpot(:,t+1)];  clpot(:,t+1) = enter_soft_evidence(engine.sub_engine, clqs, pots, ndx);end

⌨️ 快捷键说明

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