for d = 1:dsize(1)
	magn(d) = kernel(data(d,:), data(d,:));
end

zeta = 1/350;
mydata = point(:,2:23);
mysize = size(mydata);
dm = ones(mysize(1),1)*mean(mydata);
mydata = mydata - dm;

myodata = stop(:,2:23);
myosize = size(myodata);
dm = ones(myosize(1),1)*mean(myodata);
myodata = myodata - dm;

choosa = sum(M(1:choose, :));
choosb = sum(M(choose+1:2*choose, :));
thisc = choosa;
thatc = choosb;
right = 0;
wrong = 0;
maybe = 0;
ct = 0;
mygamma = [];

%for x = 1:mysize(1)
%for x = 1:mysize(1)
while(1)
	if(rand(1) > .5)
		x = floor(rand(1)*mysize(1))+1;
		thisc = choosa;
		thatc = choosb;
		me = mydata(x,:);
	else
		x = floor(rand(1)*myosize(1))+1;
		thisc = choosb;
		thatc = choosa;
		me = myodata(x,:);
	end
	for d= 1:dsize(1)
		mygamma(d) = kernel(me, data(d,:))/magn(d);
	end
	A = gamma(1,:)'*gamma(1,:);
	dis = sum(sum(A.*prekern))-2*sum(gamma(1,:).*mygamma(d));
	best = dis;
	bclust = 1;
	distance(x, 1) = dis;
	for c = 2:nclust
		A = gamma(c,:)'*gamma(c,:);
		dis = sum(sum(A.*prekern))-2*sum(gamma(c,:).*mygamma(d));
		distance(x, c) = dis;
		if(dis < best)
			best = dis;
			bclust = c;
		end
	end
	if(thisc(bclust) > thatc(bclust))
		right = right+1;
	else
		wrong = wrong+1;
	end
	wrong./(right+wrong)
	gammacor = ones(1, dsize(1)).*(1-zeta);
	gamma(bclust,:) = gamma(bclust,:).*gammacor;
	gamma(bclust,:) = gamma(bclust,:) + (zeta*mygamma);
	ct = ct+1;
	if(ct >  50)
		right = 0;
		wrong = 0;
		ct = 0;
	end
end
