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