def _centroid(self, cluster, mean):
        if self._avoid_empty_clusters:
            centroid = copy.copy(mean)
            for vector in cluster:
                centroid += vector
            return centroid / (1+len(cluster))
        else:
            if not len(cluster):
                sys.stderr.write('Error: no centroid defined for empty cluster.\n')
                sys.stderr.write('Try setting argument \'avoid_empty_clusters\' to True\n')
                assert(False)
            centroid = copy.copy(cluster[0])
            for vector in cluster[1:]:
                centroid += vector
            return centroid / len(cluster)
dataset/ETHPy150Open nltk/nltk/nltk/cluster/kmeans.py/KMeansClusterer._centroid/original