annotate toolboxes/FullBNT-1.0.7/bnt/inference/static/@gibbs_sampling_inf_engine/enter_evidence.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function [engine, loglik] = enter_evidence(engine, evidence)
wolffd@0 2 % ENTER_EVIDENCE Add the specified evidence to the network (gibbs_sampling_inf_engine)
wolffd@0 3 % [engine, loglik] = enter_evidence(engine, evidence)
wolffd@0 4 %
wolffd@0 5 % evidence{i} = [] if if X(i) is hidden, and otherwise contains its observed value
wolffd@0 6 %
wolffd@0 7 % loglik is not computed... we just return a 0 value
wolffd@0 8
wolffd@0 9 bnet = bnet_from_engine(engine);
wolffd@0 10
wolffd@0 11 engine.hnodes = find(isemptycell(evidence));
wolffd@0 12 engine.onodes = mysetdiff(1:length(evidence), engine.hnodes);
wolffd@0 13
wolffd@0 14 engine.evidence = zeros(engine.slice_size, 1);
wolffd@0 15
wolffd@0 16 % Reset all counts since they are no longer valid
wolffd@0 17 engine.marginal_counts = {};
wolffd@0 18 %engine.state = sample_bnet (bnet, 1, 0);
wolffd@0 19 engine.state = cell2num(sample_bnet(bnet));
wolffd@0 20
wolffd@0 21 % For speed, we use a normal (not cell) array. We're making use of
wolffd@0 22 % the current restriction to discrete nodes.
wolffd@0 23 for i = engine.onodes
wolffd@0 24 engine.evidence(i) = evidence{i};
wolffd@0 25 end
wolffd@0 26
wolffd@0 27 loglik = 0;
wolffd@0 28
wolffd@0 29