function EM_mixGaussPlot( M, y )
%    EM_mixGaussPlot.m
%      2 dimensional plot for mixture of Gaussians
%      EM_mixGaussPlot( M, y )
%      input
%         M : Model to be illustrated
%         y : sample data to be illustrated
idx1 = 1;
idx2 = 2;

unitstr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
plot( y(idx1,:), y(idx2,:), 'b.')
ax = axis;
hold on
range = min( [(ax(2)-ax(1)) (ax(4)-ax(3))] );

m = length(M.p);
for k=1:m
  mu = M.p(k).mu([idx1 idx2]);
  sigma = M.p(k).sigma;
  theta = 2*pi*(0:40)/40;
  x0 = mu(1)+sigma*sin(theta);
  y0 = mu(2)+sigma*cos(theta);
  plot(x0,y0,'r-','LineWidth',2)
  text(mu(1),mu(2), unitstr(k) )
end

