function halfplane(d)
% This function plots the 3-d Gaussian pdf
% for two iid N(0,1) Gaussian RVs and two
% half-planes of distance d from the origin.
x1=[-4:.1:4];
x2=[-4:.1:4];
pg=(1/(2*pi))*exp(-(x1.^2)/2)'*exp(-(x2.^2)/2);
half=zeros(81,81);
halfr=half;
for n=1:81
for m=1:81
    if(x1(n)+x2(m)<-d*sqrt(2))
        halfr(n,m)=0.1;
    end
    if(x1(n)>d)
        half(n,:)=0.1;
    end
end
end
mesh(x1,x2,pg)
hold on
mesh(x1,x2,half)
mesh(x1,x2,halfr)
hold off

