homogeneity function

Calculate within-cluster homogeneity