
twones = ones(1,20);
for k = 1:40
right = 0;
for lo = 1:40
tmp = twones;
for deg = 1:k
	tmp = [tmp; train1.^deg];
end
Y = tmp;
tmp = twones;
for deg = 1:k
	tmp = [tmp; train2.^deg];
end
preY = [Y tmp]';
Y = [Y -1*tmp]';
Z = [Y(1:(lo-1),:); Y((lo+1):40, :)];

Yi = pinv(Z);

tmp =Yi*b;
if(Y(lo, 1) > 0)
	if((tmp'*preY(lo,:)') > 0)
		right = right+1;
	end
else
	if((tmp'*preY(lo,:)') < 0)
		right = right+1;
	end
end
end
right
v(k) = right;
end
return;
test = test1;
c1 = 0;
c2=0;
for s = 1:200
	if(test(s) < 3.7558)
		c1=c1+1;
	elseif(test(s) <5.2765)
		c2=c2+1;
	elseif(test(s) < 7.4885)
		c1=c1+1;
	else
		c2=c2+1;
	end
end
	c1/(c1+c2)
return;
gn = 1./(sqrt(2*pi));
train = train1;
h = .48;
density = zeros(100,1);
for xct = 1:100
x = xct/10;
	for s = 1:20
		density(xct) = density(xct) + (gn./h)*exp(((-1/2).*(train(s)-x).^2)./(h*h));
		xv(xct) = x;
	end
end
return;

h = 1;
train = train1;
gn = 1./(sqrt(2*pi));
for hct = 1:100
h = hct/50;
lpsum = 0;
for lo = 1:20
	x = train(lo);
	density = 0;
	for s = 1:20
		if(s ~= lo)
			density = density + (gn./h)*exp(((-1/2).*(train(s)-x).^2)./(h*h));
		end
	end
	lpsum = lpsum + log(density);
end
	v(hct) = lpsum/20;
	hv(hct) = h;
end
