def clustercenter(samples):
  """
  Computes the geometric center of a set of vectors.
  samples = [ [v11,...,v1N], ... [vn1,...,vnN] ]  
  """
  N, dim = len(samples), len(samples[0])
  if N == 1: # singleton cluster
    return samples[0]
  # Cluster center is the average in all dimensions
  dsum = [0.0] * dim
  for d in range(dim):
    for i in range(N):
      dsum[d] += samples[i][d]
    dsum[d] /= N
  return dsum