[issue24567] random.choice IndexError due to double-rounding

Mark Dickinson report at bugs.python.org
Sun Jul 12 11:05:49 CEST 2015


Mark Dickinson added the comment:

Serhiy: there's already a small bias inherent in using `int(random() * n)`, regardless of double rounding, since in general `random()` gives 2**53 equally likely (modulo deficiencies in the source generator) outcomes and `n` need not be a divisor of `2**53`.  I don't think the double rounding is going to make that bias noticeably worse.

See issue 23974, which was resolved as "wont fix".

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24567>
_______________________________________


More information about the Python-bugs-list mailing list