K-means clustering is an algorithm for grouping genes or samples based on pattern into "K" groups. Grouping is done by minimizing the sum of the squares of distances between the data and the corresponding cluster centroid. Thus the purpose of K-means clustering is to classify data based on similar expression. K-means clustering algorithm and some of its variants (including k-medoids) have been shown to produce good results for gene expression data (at least better than hierarchical clustering methods). Empirical comparisons of k-means, k-medoids, hierarchical methods and, different distance measures can be found in the literature.