annotate toolboxes/FullBNT-1.0.7/bnt/examples/static/Models/mk_incinerator_bnet.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 function bnet = mk_incinerator_bnet(ns)
Daniel@0 2 % MK_INCINERATOR_BNET The waste incinerator emissions example from Cowell et al p145
Daniel@0 3 % function bnet = mk_incinerator_bnet(ns)
Daniel@0 4 %
Daniel@0 5 % If ns is omitted, we use the scalars and binary nodes and the original params.
Daniel@0 6 % Otherwise, we use random params of the desired size.
Daniel@0 7 %
Daniel@0 8 % Lauritzen, "Propogation of Probabilities, Means and Variances in Mixed Graphical Association Models",
Daniel@0 9 % JASA 87(420): 1098--1108
Daniel@0 10 % This example is reprinted on p145 of "Probabilistic Networks and Expert Systems",
Daniel@0 11 % Cowell, Dawid, Lauritzen and Spiegelhalter, 1999, Springer.
Daniel@0 12 % For a picture, see http://www.cs.berkeley.edu/~murphyk/Bayes/usage.html#cg_model
Daniel@0 13
Daniel@0 14 % node numbers
Daniel@0 15 F = 1; W = 2; E = 3; B = 4; C = 5; D = 6; Min = 7; Mout = 8; L = 9;
Daniel@0 16 names = {'F', 'W', 'E', 'B', 'C', 'D', 'Min', 'Mout', 'L'};
Daniel@0 17 n = 9;
Daniel@0 18 dnodes = [F W B];
Daniel@0 19 cnodes = mysetdiff(1:n, dnodes);
Daniel@0 20
Daniel@0 21 % node sizes - all cts nodes are scalar, all discrete nodes are binary
Daniel@0 22 if nargin < 1
Daniel@0 23 ns = ones(1, n);
Daniel@0 24 ns(dnodes) = 2;
Daniel@0 25 rnd = 0;
Daniel@0 26 else
Daniel@0 27 rnd = 1;
Daniel@0 28 end
Daniel@0 29
Daniel@0 30 % topology (p 1099, fig 1)
Daniel@0 31 dag = zeros(n);
Daniel@0 32 dag(F,E)=1;
Daniel@0 33 dag(W,[E Min D]) = 1;
Daniel@0 34 dag(E,D)=1;
Daniel@0 35 dag(B,[C D])=1;
Daniel@0 36 dag(D,[L Mout])=1;
Daniel@0 37 dag(Min,Mout)=1;
Daniel@0 38
Daniel@0 39 % params (p 1102)
Daniel@0 40 bnet = mk_bnet(dag, ns, 'discrete', dnodes, 'names', names);
Daniel@0 41
Daniel@0 42 if rnd
Daniel@0 43 for i=dnodes(:)'
Daniel@0 44 bnet.CPD{i} = tabular_CPD(bnet, i);
Daniel@0 45 end
Daniel@0 46 for i=cnodes(:)'
Daniel@0 47 bnet.CPD{i} = gaussian_CPD(bnet, i);
Daniel@0 48 end
Daniel@0 49 else
Daniel@0 50 bnet.CPD{B} = tabular_CPD(bnet, B, 'CPT', [0.85 0.15]); % 1=stable, 2=unstable
Daniel@0 51 bnet.CPD{F} = tabular_CPD(bnet, F, 'CPT', [0.95 0.05]); % 1=intact, 2=defect
Daniel@0 52 bnet.CPD{W} = tabular_CPD(bnet, W, 'CPT', [2/7 5/7]); % 1=industrial, 2=household
Daniel@0 53 bnet.CPD{E} = gaussian_CPD(bnet, E, 'mean', [-3.9 -0.4 -3.2 -0.5], ...
Daniel@0 54 'cov', [0.00002 0.0001 0.00002 0.0001]);
Daniel@0 55 bnet.CPD{D} = gaussian_CPD(bnet, D, 'mean', [6.5 6.0 7.5 7.0], ...
Daniel@0 56 'cov', [0.03 0.04 0.1 0.1], 'weights', [1 1 1 1]);
Daniel@0 57 bnet.CPD{C} = gaussian_CPD(bnet, C, 'mean', [-2 -1], 'cov', [0.1 0.3]);
Daniel@0 58 bnet.CPD{L} = gaussian_CPD(bnet, L, 'mean', 3, 'cov', 0.25, 'weights', -0.5);
Daniel@0 59 bnet.CPD{Min} = gaussian_CPD(bnet, Min, 'mean', [0.5 -0.5], 'cov', [0.01 0.005]);
Daniel@0 60 bnet.CPD{Mout} = gaussian_CPD(bnet, Mout, 'mean', 0, 'cov', 0.002, 'weights', [1 1]);
Daniel@0 61 end