kmeans - NaN Centroids

In the kmeans function if no sample is matched to a given centroid during an iteration then there is a divide by zero and the centroid becomes NaN (line 76)