dimanche 22 septembre 2019

Generate list of random number with condition - numpy

I would like to generate a list of 15 integers with sum 12, minimum value is 0 and maximum is 6.

I tried following code

def generate(low,high,total,entity):
   while sum(entity)!=total:
       entity=np.random.randint(low, high, size=15)
   return entity

But above function is not working properly.




Aucun commentaire:

Enregistrer un commentaire