[issue37624] random.choices has unexpected behavior with negative weights

2019-07-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: Misc side notes: * There is no expected behavior for negative a negative weight. Arguably, the only reasonable interpretation is what it already does (reduce the cumulative total). * Running simulations is a primary use case for choices(). Generally, r

[issue37624] random.choices has unexpected behavior with negative weights

2019-07-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset a50a6225a06e5a83ce2a880a7eb4496043fdbb55 by Raymond Hettinger (Miss Islington (bot)) in branch '3.8': bpo-37624: Document weight assumptions for random.choices() (GH-14855) (GH-14858) https://github.com/python/cpython/commit/a50a6225a06e5a83

[issue37624] random.choices has unexpected behavior with negative weights

2019-07-19 Thread miss-islington
Change by miss-islington : -- pull_requests: +14648 pull_request: https://github.com/python/cpython/pull/14858 ___ Python tracker ___ __

[issue37624] random.choices has unexpected behavior with negative weights

2019-07-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 8dbe563aa6bd18b8c581951537dfb406d36e8063 by Raymond Hettinger in branch 'master': bpo-37624: Document weight assumptions for random.choices() (GH-14855) https://github.com/python/cpython/commit/8dbe563aa6bd18b8c581951537dfb406d36e8063 -

[issue37624] random.choices has unexpected behavior with negative weights

2019-07-19 Thread Raymond Hettinger
Change by Raymond Hettinger : -- pull_requests: +14645 pull_request: https://github.com/python/cpython/pull/14855 ___ Python tracker ___ ___

[issue37624] random.choices has unexpected behavior with negative weights

2019-07-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: We can add a note the the docs that weights are assumed to be non-negative, but I don't want to add an extra O(n) step to check for unusual inputs with undefined meaning -- that would just impair the normal use cases for near zero benefit. -- ass

[issue37624] random.choices has unexpected behavior with negative weights

2019-07-18 Thread Aldwin Pollefeyt
Change by Aldwin Pollefeyt : -- keywords: +patch pull_requests: +14644 stage: -> patch review pull_request: https://github.com/python/cpython/pull/14854 ___ Python tracker ___

[issue37624] random.choices has unexpected behavior with negative weights

2019-07-18 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +mark.dickinson, rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list U

[issue37624] random.choices has unexpected behavior with negative weights

2019-07-18 Thread Aldwin Pollefeyt
Aldwin Pollefeyt added the comment: This is what happens with your weights: >>> list(itertools.accumulate(weights)) [1, 2, 1, 2, 3, 3, 4] using bisect.bisect certain amount of times, will distribute on this: a<1 ___

[issue37624] random.choices has unexpected behavior with negative weights

2019-07-18 Thread Ted Whalen
New submission from Ted Whalen : The behavior of random.choices when negative weights are provided is unexpected. While giving a negative weight for one value is probably bad, it's really unfortunate that providing a negative weight for one value affects the probability of selecting an adjace