% Plots of bivariate normal distribution

x = [0 ; 0];
mu = [0 ; 0];
% sigma =  [ 1 0 ; 0 1];
% sigma =  [ 1 .5 ; .5 1];
sigma = [1 -.5 ; -.5 1];

n0=51;
x1=-4:8/(n0-1):4;
x2=-4:8/(n0-1):4;
pdf=zeros(n0,n0);

for i = 1:1:n0;
  for j = 1:1:n0;
    x(1)=x1(i);
    x(2)=x2(j);
    pdf(i,j)=(1/(sqrt(2*pi*det(sigma))))*exp(-(x-mu)'*inv(sigma)*(x-mu)/2);
  end
end

mesh(x1,x2,pdf);
% contour(x1,x2,pdf);
xlabel('x1'), ylabel('x2'), zlabel('pdf'); 
title(['Bivariate Normal, rho = ',num2str(sigma(1,2))]);

return