def dist_average (c0, c1): return Vector.distance(avg(c0), avg(c1))
def sum_of_squared_errors (self): normsq = lambda v : abs(Vector.norm(v, 1)) clust_avg = lambda clst : (clst, avg(clst)) clust_sqerr = lambda (clst, mu) : sum(normsq(v - mu) for v in clst) return sum( it.imap(clust_sqerr, it.imap(clust_avg, self)) )