annotate toolboxes/FullBNT-1.0.7/bnt/examples/static/sample1.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 % Check sampling on a mixture of experts model
wolffd@0 2 %
wolffd@0 3 % X \
wolffd@0 4 % | |
wolffd@0 5 % Q |
wolffd@0 6 % | /
wolffd@0 7 % Y
wolffd@0 8 %
wolffd@0 9 % where all arcs point down.
wolffd@0 10 % We condition everything on X, so X is a root node. Q is a softmax, and Y is a linear Gaussian.
wolffd@0 11 % Q is hidden, X and Y are observed.
wolffd@0 12
wolffd@0 13 X = 1;
wolffd@0 14 Q = 2;
wolffd@0 15 Y = 3;
wolffd@0 16 dag = zeros(3,3);
wolffd@0 17 dag(X,[Q Y]) = 1;
wolffd@0 18 dag(Q,Y) = 1;
wolffd@0 19 ns = [1 2 2];
wolffd@0 20 dnodes = [2];
wolffd@0 21 bnet = mk_bnet(dag, ns, dnodes);
wolffd@0 22
wolffd@0 23 x = 0.5;
wolffd@0 24 bnet.CPD{1} = root_CPD(bnet, 1, x);
wolffd@0 25 bnet.CPD{2} = softmax_CPD(bnet, 2);
wolffd@0 26 bnet.CPD{3} = gaussian_CPD(bnet, 3);
wolffd@0 27
wolffd@0 28 data_case = sample_bnet(bnet, 'evidence', {0.8, [], []})
wolffd@0 29 ll = log_lik_complete(bnet, data_case)
wolffd@0 30
wolffd@0 31 data_case = sample_bnet(bnet, 'evidence', {-11, [], []})
wolffd@0 32 ll = log_lik_complete(bnet, data_case)
wolffd@0 33
wolffd@0 34