[issue40541] Add optional weights parameter to random.sample()

2020-05-08 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue40541] Add optional weights parameter to random.sample()

2020-05-08 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 81a5fc38e81b424869f4710f48e9371dfa2d3b77 by Raymond Hettinger in branch 'master': bpo-40541: Add optional *counts* parameter to random.sample() (GH-19970) https://github.com/python/cpython/commit/81a5fc38e81b424869f4710f48e9371dfa2d3b77

[issue40541] Add optional weights parameter to random.sample()

2020-05-07 Thread Raymond Hettinger
Raymond Hettinger added the comment: > How about "counts" instead of "weights"? That makes sense. -- ___ Python tracker ___ ___

[issue40541] Add optional weights parameter to random.sample()

2020-05-07 Thread Mark Dickinson
Mark Dickinson added the comment: +1 for the functionality. How about "counts" instead of "weights"? I found the name "weights" misleading - my first thought was that this would be doing a weighted sampling without replacement (like NumPy's `random.choice(..., replace=False, p=weights)`).

[issue40541] Add optional weights parameter to random.sample()

2020-05-07 Thread Mark Dickinson
Change by Mark Dickinson : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue40541] Add optional weights parameter to random.sample()

2020-05-06 Thread Raymond Hettinger
Change by Raymond Hettinger : -- keywords: +patch pull_requests: +19286 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19970 ___ Python tracker

[issue40541] Add optional weights parameter to random.sample()

2020-05-06 Thread Raymond Hettinger
New submission from Raymond Hettinger : I've seen multiple requests for this and it isn't obvious how to do it with the existing tooling. The example currently given in the recipes section isn't scalable because it involves expanding the population into a big list with repeated elements: