%problem 1 disp('(1)'); beta=-2:0.5:2; pr=1+normcdf(-1.645-beta)-normcdf(1.645-beta); disp([beta;pr]); %problem 2 %(b) disp('(2a)'); MAX=100000; beta=[-1 -1 -1 0 0 0 1 1 1 1 0 -1 1 0 -1 1 0 -1]; r=0.6; C=[sqrt(1-r*r) r; 0 1]; pra=zeros(1,9); for j=1:9 for i=1:MAX z=randn(2,1); b=beta(:,j)+C*z; W0=b'*inv(C*C')*b; if W0>5.99 pra(j)=pra(j)+1; end end end pra=pra/MAX; disp([beta; pra]); disp('(2b)'); r=-0.6; C=[sqrt(1-r*r) r; 0 1]; prb=zeros(1,9); for j=1:9 for i=1:MAX z=randn(2,1); b=beta(:,j)+C*z; W0=b'*inv(C*C')*b; if W0>5.99 prb(j)=prb(j)+1; end end end prb=prb/MAX; disp([beta; prb]);