mercredi 11 janvier 2017

How to restrict values of np.random with some non-normal distribution to an interval?

I am seeking a random array with non-normal distribution and values in some defined interval, say, from -100 to 100. I cannot see how to do that with the arguments available in numpy.random.name_of_distribution. For example,

k = np.random.noncentral_chisquare(1, 50, 100)

has arguments (degrees of freedom, noncentrality and size). The range of values seems to depend on where I set that noncentrality; in other words, changing it to 90 moves the top end of the distribution up to 120 or 130.

np.random.exponential(10,100) 

is producing a range from 0 to 60 or so. Must one be clever and rescale the output algebraically, or is there a quicker fix?




Aucun commentaire:

Enregistrer un commentaire