Just like the picture,why not just choose the point 2 as the second point of the cluster?But go to generate a random number bettwen [0,1]?
def initialize(X, K):#kmean++
m,n=shape(X)
C = mat(zeros((K,n)))
random_number=random.randint(0,m)
C[0,:]=X[random_number]
for k in range(1, K):
D2 = scipy.array([min([scipy.inner(c-x,c-x) for c in C]) for x in X])
probs = D2/D2.sum()
cumprobs = probs.cumsum()
r = scipy.rand()
for j,p in enumerate(cumprobs):
if r < p:
i = j
break
C[k,:]=X[i]
return C
Why generate r to compare with the p(the cumaltive probablity in picture is Sum)?