I'm a beginner and learning Python for 2 Months.
I need to generate random 5 float numbers in range [-1,1] and normalize it. The sum of this random numbers has to be always 1. It's quite important.
a = np.random.random(5)*2 -1 #generate 5 numbers in range [-1,1]
But how to make the sum of them = 1?
a /= np.sum(a) # Doesn't work
I need some help.
Aucun commentaire:
Enregistrer un commentaire