4 ms·
In Python: random.choices(population=['A', 'B', 'C', 'D'], weights=[3, 2, 5, 7]) https://docs.python.org/3/library/random.html#random.c
by jefftk 4y ago
In Python:
random.choices(population=['A', 'B', 'C', 'D'],
weights=[3, 2, 5, 7])
https://docs.python.org/3/library/random.html#random.choices https://docs.python.org/3/library/random.html#random.choices
- EarthLaunch 4y agoThank you very much! That led me to a JS clone[0]. Python has amazing math libraries. I use numjs[1] for everything, which is a port of numpy. I frequently wish I had use of Python's libraries. 0: https://github.com/parmentf/random-weighted-choice https://github.com/parmentf/random-weighted-choice 1: https://github.com/nicolaspanel/numjs https://github.com/nicolaspanel/numjs