clust_samp_func function

Performs clustering of samples.