mysig = 15;
myncl = 5;
[g1 k1 cdat1] = gmmnl2(cpoint, myncl, mysig);
[g2 k2 cdat2] = gmmnl2(cstop, myncl, mysig);

srfa = gmmsurf(g1, k1, cdat1, myncl, mysig);
srfb = gmmsurf(g2, k2, cdat2, myncl, mysig);

hold off;
surf(xv, xv, srfa, ones(size(srfa)));
hold on;
surf(xv, xv, srfb, zeros(size(srfb)));

plot(cdat2(:,1), cdat2(:,2), 'white*');
plot(cdat1(:,1), cdat1(:,2), 'greenx')  


right = 0;
tot = 0;
for x = 1:50
	ap(x) = nldist(cdat1(x, :), cdat1, myncl, mysig, g1, k1)/myncl;
	bp(x) = nldist(cdat2(x, :), cdat1, myncl, mysig, g1, k1)/myncl;
	cp(x) = nldist(cdat1(x, :), cdat2, myncl, mysig, g2, k2)/myncl;
	dp(x) = nldist(cdat2(x, :), cdat2, myncl, mysig, g2, k2)/myncl;
	tot = tot+1;
	if(cp(x) < ap(x))
		x
		right = right+1
	else
		plot(cdat1(x,1), cdat1(x,2), 'blacko');
	end
	if(bp(x) < dp(x))
		x
		right = right+1
	else
		plot(cdat2(x,1), cdat2(x,2), 'blacko');
	end
%	ap(x) = nldist(cpoint(x, :), cdat1, myncl, mysig, g1, k1)/myncl;
%	bp(x) = nldist(cstop(x, :), cdat1, myncl, mysig, g1, k1)/myncl;
%	cp(x) = nldist(cpoint(x, :), cdat2, myncl, mysig, g2, k2)/myncl;
%	dp(x) = nldist(cstop(x, :), cdat2, myncl, mysig, g2, k2)/myncl;
end
right
tot*2