Issue 18888: Add stdlib support for random sampling with replacement (original) (raw)

Issue18888

Created on 2013-08-31 00:23 by madison.may, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg196603 - (view) Author: Madison May (madison.may) * Date: 2013-08-31 00:23
Although the random module supports random sampling without replacement, there is no support for random sampling with replacement. Efficient random sampling with replacement is trivial using random.choice() (see below), but supporting it as an optional 'replace' arg to random.sample() might be nice for symmetry. array = range(100) random_sample = [random.choice(array) for i in range(10)]
msg196626 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2013-08-31 09:24
This was already considered and rejected in .
msg196631 - (view) Author: Madison May (madison.may) * Date: 2013-08-31 11:30
Whoops, my apologies.
History
Date User Action Args
2022-04-11 14:57:50 admin set github: 63088
2013-08-31 11:30:56 madison.may set messages: +
2013-08-31 09:24:21 mark.dickinson set status: open -> closednosy: + rhettinger, mark.dickinsonmessages: + superseder: random.choices(seq, k)resolution: duplicate
2013-08-31 00:23:49 madison.may create