I have seen other posts addressing similar problem. I know how to generate N positive integers. I also know how to restrict the sum of randomly generated integers. The only problem is satisfying the condition that none of the N values fall out of the specified range.
e.g. generate_ints(n, total, low, high)
should generate n value array such that each value is between low and high and the sum adds up to the total. Any pointers/ help would be greatly appreciated.
e.g.generate_ints(4, 40, 4, 15)
should generate something like
[7,10,13,10]
I don't care if the numbers are repeated, as long as they are not highly skewed. I am using np.randon.randint(5,15,n)
to select the integer.
Thanks again.
Aucun commentaire:
Enregistrer un commentaire