% data = genSample_net1(N) generates N samples form Network 1 in % Figure 4 % data is NxM matrix where each row corresponds to sample from the network % the columns are ordered as: A,B,C,D,E function data = genSample_net1(N) %number of variables M = 5; A=1; B=2; C=3; D=4; E=5; %simple encoding of the bayesian network for problem 1 condProb = cell(M,1); parents = cell(M,1); condProb{A}=.2; condProb{B}= .2; condProb{C} =[.1, .6, .6, .8]; condProb{D}= [.3, .7 ]; condProb{E}= [.3, .7]; parents{A}=[]; parents{B}= []; parents{C}= [A B]; parents{D}= C; parents{E}= C; %the seed number should be function of alpha and N rand('state',10000*N); data= size(N,M); for i=1:N for j=1:M if(~isempty(parents{j})) parentsValue = data(i,parents{j}); else parentsValue=[]; end prob = condProb{j}(toInt(parentsValue)+1); if(rand