Completed implementation of distribution knn computation (but speedup seems very limited)