[issue18844] allow weights in random.choice
Neil Girdhar
report at bugs.python.org
Thu Sep 12 04:57:46 CEST 2013
Neil Girdhar added the comment:
Should this really be implemented using the cumulative distribution and binary search algorithm? Vose's Alias Method has the same initialization and memory usage cost (O(n)), but is constant time to generate each sample.
An excellent tutorial is here: http://www.keithschwarz.com/darts-dice-coins/
----------
nosy: +neil.g
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18844>
_______________________________________
More information about the Python-bugs-list
mailing list