mardi 6 novembre 2018

random sample n digits from range of (x,y) that average to mean k?

I am trying to random sample n=15 digits from range(low=3, high=7) that when summing the sampled 15 digits, they average to 5.

So far I've managed only to random sample n digits from certain range like:

n = 15
low  = 3
high = 8
range=[i for i in range(low,high)]
list =np.random.choice(range, n)

This generates random 15 digits of integers ranging from 3, 4, 5, 6, 7. However, I want it randomly sampled, yet the resulted average of the n digit sums equal 5? How can I go about this?




Aucun commentaire:

Enregistrer un commentaire