[issue47114] random.choice and random.choices have different distributions

2022-03-24 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue47114] random.choice and random.choices have different distributions

2022-03-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: This was an intentional decision. It is documented and tested. The rationale is that is keeps choices() internally consistent so that choices with equal weights produces the same result as if no weights are specified. For anyone who wants an

[issue47114] random.choice and random.choices have different distributions

2022-03-24 Thread Tim Peters
Tim Peters added the comment: Definitely a duplicate, and I doubt Mark or Raymond will change their mind. One observation: while floats are not uniformly dense in [0, 1), random() results are uniformly spaced. Each is of the form I / 2**53 for an integer I in range(2**53). -- nosy:

[issue47114] random.choice and random.choices have different distributions

2022-03-24 Thread Dennis Sweeney
Dennis Sweeney added the comment: Possible duplicate of https://bugs.python.org/issue44080 -- nosy: +Dennis Sweeney ___ Python tracker ___

[issue47114] random.choice and random.choices have different distributions

2022-03-24 Thread Mark Bell
Mark Bell added the comment: To give two more consequences of `random.choices` using floating point arithmetic: 1) When doing `random.choices([A, B, C], weights=[2**55, 1, 1])` the cumulative weight to bisect for is selected using `floor(random() * (2**55 + 1 + 1 + 0.0))`. Since this is

[issue47114] random.choice and random.choices have different distributions

2022-03-24 Thread Mark Bell
New submission from Mark Bell : The docstring for `random.choices` indicates that ``` import random random.choices(population, k=1) ``` should produce a list containing one item, where each item of `population` has equal likelihood of being selected. However `random.choices` draws elements for