for i in range(data.shape[0] - 1):
    tot += (((data[i + 1:] - data[i]) ** 2).sum(1) ** 0.5).sum()
avg = tot / ((data.shape[0] - 1) * data.shape[0] / 2.0)
Using Numpy to find the average distance in a set of points