function yt = kneighbor(xt, x, y, k)
%kneighbor	K Neighbor
%	yt = kneighbor(xt, x, y);
%
%	x: centers (2 * N)
%	y: corresponding output (1 * N)

%	Ling Li, Caltech
%	11/11/2000

[sd, id] = sort(dist2(xt, x), 2);

if k > 1
	yt = sign(sum(y(id(:,1:k)),2))';
else %	k == 1
	yt = y(id(:,1));
end;
