mu = .003;
w = [ 0;  1; 0];
clear errplot;

for it= 1:100
	for i = 1:250
 		x = [traina(i,:) 1]';
		e = w'*x;
		y = 1/(1+exp(-1*e));
		ystar = 1;
		w = w + (mu*(ystar-y)*x);
		tmp = (mu*(ystar-y)*x);

 		x = [trainb(i,:) 1]';
		e = w'*x;
		y = 1/(1+exp(-1*e));
		ystar = 0;
		w = w + (mu*(ystar-y)*x);
		tmp = tmp+ (mu*(ystar-y)*x);
	end

	err = 0;
	for i = 1:250
		tx = [testa(i,:) 1]';
		te = w'*tx;
		ty = 1/(1+exp(-1*te));
%		This line for cross entropy error estimate
		err = err- ystar*log(ty) - (1-ystar)*log(1-y);

%		This line for least squares error estimate
%		err = err + (ty-1)*(ty-1);

		tx = [testb(i,:) 1]';
		te = w'*tx;
		ty = 1/(1+exp(-1*te));
%		This line for cross entropy error estimate
		err = err- ystar*log(ty) - (1-ystar)*log(1-y);

%		This line for least squares error estimate
%		err = err + (ty)*(ty);
	end
	errplot(it) = err;

	it
	w
	hold off
	xes = -2:.1:4;
	yes = -w(1)*xes/w(2) - w(3)/w(2);
	plot(xes, yes);
	hold on
	plot(traina(:,1), traina(:,2), 'redx');
	plot(trainb(:,1), trainb(:,2), 'blueo');
	hold off
	pause(.1);
end
