homepage

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.

classification
Title: Add stdlib support for random sampling with replacement
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.4, Python 3.5
process
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.
History
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

AltStyle によって変換されたページ (->オリジナル) /