Since numpy version 1.7 you can use numpy.random.choice():
numpy.random.choice()
elements = ['one', 'two', 'three'] weights = [0.2, 0.3, 0.5] from numpy.random import choice print(choice(elements, p=weights))
1.4m articles
1.4m replys
5 comments
57.0k users