[Numpy-discussion] weighted random integers
josef.pktd@gmai...
josef.pktd@gmai...
Fri Sep 10 18:46:05 CDT 2010
I saw some questions on the web how to create non-uniform random
integers in python.
I don't know what the best way is but here is another way that looks
reasonably fast
>>> rvs = np.dot(np.random.multinomial(1, [0.1, 0.2, 0.5, 0.2], size=1000000),np.arange(4))
>>> np.bincount(rvs)/1000000.
array([ 0.099741, 0.199943, 0.499317, 0.200999])
Josef
More information about the NumPy-Discussion
mailing list