diff toolboxes/FullBNT-1.0.7/bnt/examples/static/sample1.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/examples/static/sample1.m	Fri Aug 19 13:07:06 2016 +0200
@@ -0,0 +1,34 @@
+% Check sampling on a mixture of experts model
+%
+%  X \
+%  | |
+%  Q |
+%  | /
+%  Y
+%
+% where all arcs point down.
+% We condition everything on X, so X is a root node. Q is a softmax, and Y is a linear Gaussian.
+% Q is hidden, X and Y are observed.
+
+X = 1;
+Q = 2;
+Y = 3;
+dag = zeros(3,3);
+dag(X,[Q Y]) = 1;
+dag(Q,Y) = 1;
+ns = [1 2 2];
+dnodes = [2];
+bnet = mk_bnet(dag, ns, dnodes);
+
+x = 0.5;
+bnet.CPD{1} = root_CPD(bnet, 1, x);
+bnet.CPD{2} = softmax_CPD(bnet, 2);
+bnet.CPD{3} = gaussian_CPD(bnet, 3);
+
+data_case = sample_bnet(bnet, 'evidence', {0.8, [], []})
+ll = log_lik_complete(bnet, data_case)
+
+data_case = sample_bnet(bnet, 'evidence', {-11, [], []})
+ll = log_lik_complete(bnet, data_case)
+
+