diff toolboxes/FullBNT-1.0.7/bnt/general/enumerate_scenarios.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toolboxes/FullBNT-1.0.7/bnt/general/enumerate_scenarios.m	Fri Aug 19 13:07:06 2016 +0200
@@ -0,0 +1,21 @@
+function [scenarios, log_probs] = enumerate_scenarios(bnet, evidence)
+% ENUMERATE_SCENARIOS Enumerate all assignments, and return the prob. of the non-zeros ones
+% function [scenarios, log_probs] = enumerate_scenarios(bnet, evidence)
+
+assert(isempty(bnet.cnodes));
+n = length(bnet.dag);
+observed = ~isemptycell(evidence);
+vals = cat(1,evidence{observed});
+vals = vals(:)';
+ns = bnet.node_sizes;
+
+log_probs = [];
+scenarios = [];
+for i=1:prod(ns)
+  inst = ind2subv(ns, i); % i'th instantiation
+  if isempty(vals) | inst(observed) == vals % agrees with evidence
+    ll = log_lik_complete(bnet, num2cell(inst(:)));
+    log_probs = [log_probs ll];
+    scenarios = [scenarios(:)' inst];
+  end
+end