Message393333
FWIW, the principal use case that choices() was designed for is resampling/bootstapping. In that use case, speed matters and small imbalances in large sequences don't matter at all. Also, the API was designed to make it easy to select from an itemized population of individuals than a large range followed by a modulo calculation (we already have randrange() to meet that need).
I could add a sentence to the last paragraph recommending "[choice(pop) for i in range(k)]" for the case where 1) the population is large, 2) the speed doesn't matter, 3) the weights are equal, and 4) integer math is desired to avoid any trace of bias. That said, I don't users would benefit from it and that this is largely just a theoretical concern that doesn't warrant more than the existing paragraph. |
|
Date |
User |
Action |
Args |
2021-05-09 18:58:59 | rhettinger | set | recipients:
+ rhettinger, mark.dickinson, Dennis Sweeney |
2021-05-09 18:58:59 | rhettinger | set | messageid: <1620586739.88.0.510443305498.issue44080@roundup.psfhosted.org> |
2021-05-09 18:58:59 | rhettinger | link | issue44080 messages |
2021-05-09 18:58:59 | rhettinger | create | |
|