Daniel@0: function bnet = mk_cancer_bnet(CPD_type, p) Daniel@0: % MK_CANCER_BNET Make the 'Cancer' Bayes net. Daniel@0: % Daniel@0: % BNET = MK_CANCER_BNET uses the noisy-or parameters specified in Fig 4a of the UAI98 paper by Daniel@0: % Friedman, Murphy and Russell, "Learning the Structure of DPNs", p145. Daniel@0: % Daniel@0: % BNET = MK_CANCER_BNET('noisyor', p) makes each CPD a noisy-or, with probability p of Daniel@0: % suppression for each parent; leaks are turned off. Daniel@0: % Daniel@0: % BNET = MK_CANCER_BNET('cpt', p) uses random CPT parameters drawn from a Dirichlet(p,p,...) Daniel@0: % distribution. If p << 1, this is near deterministic; if p >> 1, this is near 1/k. Daniel@0: % p defaults to 1.0 (uniform distribution). Daniel@0: % Daniel@0: % BNET = MK_CANCER_BNET('bool') makes each CPT a random boolean function. Daniel@0: % Daniel@0: % In all cases, the root is set to a uniform distribution. Daniel@0: Daniel@0: if nargin == 0 Daniel@0: rnd = 0; Daniel@0: else Daniel@0: rnd = 1; Daniel@0: end Daniel@0: Daniel@0: n = 5; Daniel@0: dag = zeros(n); Daniel@0: dag(1,[2 3]) = 1; Daniel@0: dag(2,4) = 1; Daniel@0: dag(3,4) = 1; Daniel@0: dag(4,5) = 1; Daniel@0: Daniel@0: ns = 2*ones(1,n); Daniel@0: bnet = mk_bnet(dag, ns); Daniel@0: Daniel@0: if ~rnd Daniel@0: bnet.CPD{1} = tabular_CPD(bnet, 1, [0.5 0.5]); Daniel@0: bnet.CPD{2} = noisyor_CPD(bnet, 2, 1.0, 1-0.9); Daniel@0: bnet.CPD{3} = noisyor_CPD(bnet, 3, 1.0, 1-0.2); Daniel@0: bnet.CPD{4} = noisyor_CPD(bnet, 4, 1.0, 1-[0.7 0.6]); Daniel@0: bnet.CPD{5} = noisyor_CPD(bnet, 5, 1.0, 1-0.5); Daniel@0: else Daniel@0: switch CPD_type Daniel@0: case 'noisyor', Daniel@0: for i=1:n Daniel@0: ps = parents(dag, i); Daniel@0: bnet.CPD{i} = noisyor_CPD(bnet, i, 1.0, p*ones(1,length(ps))); Daniel@0: end Daniel@0: case 'bool', Daniel@0: for i=1:n Daniel@0: bnet.CPD{i} = boolean_CPD(bnet, i, 'rnd'); Daniel@0: end Daniel@0: case 'cpt', Daniel@0: for i=1:n Daniel@0: bnet.CPD{i} = tabular_CPD(bnet, i, p); Daniel@0: end Daniel@0: otherwise Daniel@0: error(['bad CPD type ' CPD_type]); Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: Daniel@0: