function [ C ] = do_kppv(X, xa, Sa, k)

distances = zeros(size(xa, 1), 1);

for i = 1 : size(xa, 1)
    distances(i) = norm(xa(i,:) - X);
end;

[ d, i ] = sort(distances);
closest = Sa(i(1:k));
freqs = zeros(1, 10);
for j = 1 : 10
    freqs(j) = size(find(closest == j), 1) / size(Sa, 1);
end;
[ v, C ] = max(freqs);