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