One dimensional k-means implementatio