mardi 11 juillet 2017

Random Number Generator with given Interval and Mean in Python

I am using Python 2.7.12 with Anaconda 4.2.0 (64-bit). Trying to generate random numbers with the random package. I need to generate n numbers within an interval and their mean should be a specified value. For example:

I want 14 randomly generated numbers between 42,000 and 91,000 and I want these numbers to have a mean of 60,000.

I know how to use random to produce integer numbers:

random.randint(42000, 91000)

and I can put this in a for loop, but, how can I adjust their mean as 60,000?




Aucun commentaire:

Enregistrer un commentaire