mardi 28 avril 2020

Numpy array with the given values and the sum equal 1

I want to create random np.array with values including only [0.05, 0.1, 0.15, ... 0.9, 0.95, 1] with the sum of the values = 1

I know how to create a random array, for example, of 5 elements, so that the sum is equal to 1:

array = np.random.random(5)
array /= np.sum(array)

But how can I make that the values in this array are only from [0.05, 0.1, 0.15, ... 0.9, 0.95, 1]?




Aucun commentaire:

Enregistrer un commentaire