updated kmeans function

*Added function to estimate the similarity of two vectors of centroids.
*fixed a bug that prevented distances to be calculated properly.