function M=nmd2mise(H,n,w,sigma,mu)

% NMD2MISE    MISE(h) for bi-variate normal mixture densities.
%
%             Example:
%                      
%             [h1,h2]=meshgrid(0.05:0.05:0.95);
%             for i=1:19,
%               for j=1:19,
%                 H=[h1(i,j)^2 0;0 h2(i,j)^2];
%                 M(i,j)=nmd2mise(H,100,1,eye(2),[0 0]');
%               end;
%             end;
%             [y,i]=min(M); [z,j]=min(y); i=i(j);
%             H=[h1(i,j)^2 0;0 h2(i,j)^2]
%
%             NMD2MISE(H,N,W,SIGMA,MU)
%
%             Christian C. Beardah 1996

k=length(w);

M=1/(4*pi*n*sqrt(det(H)));

for i=1:k,
  for j=1:k,
    omega0(i,j)=npdf2(mu(1,i)-mu(1,j),mu(2,i)-mu(2,j),[0 0]',sigma(:,(2*i-1):2*i)+sigma(:,(2*j-1):2*j));
    omega1(i,j)=npdf2(mu(1,i)-mu(1,j),mu(2,i)-mu(2,j),[0 0]',H+sigma(:,(2*i-1):2*i)+sigma(:,(2*j-1):2*j));
    omega2(i,j)=npdf2(mu(1,i)-mu(1,j),mu(2,i)-mu(2,j),[0 0]',2*H+sigma(:,(2*i-1):2*i)+sigma(:,(2*j-1):2*j));    
  end;
end;

M=M+w'*((1-1/n)*omega2-2*omega1+omega0)*w;