function z=npdf2(x,y,mu,sigma)

% NPDF2       Bi-variate Normal probability density function.
%
%             Example: npdf2(0,0,[0 0]',eye(2))
% 
%             NPDF2(X,Y,MU,SIGMA) calculates the bi-variate normal 
%             pdf at (X,Y).  If MU (mean) and SIGMA (covariance matrix) 
%             are omitted, values of (0,0) and I_2 are assumed.
%
%             Christian C. Beardah 1995

if nargin==2,
  sigma=eye(2);
  mu=[0 0]';
end;

m=inv(sqrtm(sigma));

x=x-mu(1)*ones(size(x));
y=y-mu(2)*ones(size(y));

z=knorm(m(1,1)*x+m(1,2)*y,m(2,1)*x+m(2,2)*y)/sqrt(det(sigma));