[issue34227] Weighted random.sample() (weighted sampling without replacement)

Raymond Hettinger report at bugs.python.org
Thu Jul 26 02:42:37 EDT 2018


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

Thank for the suggestion and patch, but I will decline.  To me, the reseviour style algorithm doesn't fit in well (with the slow sorting step and the frequent calls to the random in the key function). For large population sizes (which sample() was designed for), the API and algorithm perform badly.  For typical student "urn problems", the better approach is to pre-weight the population by the exact counts specified in the problem.  I recommend that you post a recipe for what you want to do, but I don't think the standard library is the place for it.

----------
resolution:  -> rejected
stage: patch review -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34227>
_______________________________________


More information about the Python-bugs-list mailing list