This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Add stdlib support for random sampling with replacement
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.4, Python 3.5
Status: closed Resolution: duplicate
Dependencies: Superseder: random.choices(seq, k)
View: 18414
Assigned To: Nosy List: madison.may, mark.dickinson, rhettinger
Priority: normal Keywords:

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 issue18414.
msg196631 - (view) Author: Madison May (madison.may) * Date: 2013-08-31 11:30
Whoops, my apologies.
Date User Action Args
2022-04-11 14:57:50adminsetgithub: 63088
2013-08-31 11:30:56madison.maysetmessages: + msg196631
2013-08-31 09:24:21mark.dickinsonsetstatus: open -> closed

nosy: + rhettinger, mark.dickinson
messages: + msg196626

superseder: random.choices(seq, k)
resolution: duplicate
2013-08-31 00:23:49madison.maycreate