samedi 10 février 2018

Generate 3 different random number in Python

I am beginner in python. I want to generate 3 set of different number within specified range using randint in python3. (F.Y.I -> Want to implement K-Means) I am using this code

# Number of clusters
k = 3
# X coordinates of random centroids
C_x = np.random.randint(38.8, 39.4, size=k)
# Y coordinates of random centroids
C_y = np.random.randint(-77.5,-76.5, size=k)
C = np.array(list(zip(C_x, C_y)), dtype=np.float32)
print(C)

But each iteration gives me same set of values

[[ 38. -77.]
 [ 38. -77.]
 [ 38. -77.]]

Where am i going wrong?

Thanks.




Aucun commentaire:

Enregistrer un commentaire