[issue38881] unexpected behaviour of random.choices with zero weights

Raymond Hettinger report at bugs.python.org
Fri Nov 22 05:35:37 EST 2019


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

xtreak, the other discussion isn't similar at all.  The OP is proposing that weights all equal to zero be a well-defined way to specify an equiprobable selection.  That is a completely new proposal which is easy to implement, but doesn't make much sense to me.  

The current concept is that the weights express an odds ratio where a zero weight means that an event has no chance of being selected.  This view implies that if all weights are zero, the result is undefined (or an error).

Iza, it seems to me that the provided examples are conflating a zero incremental preference with a zero chance of occurrence.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38881>
_______________________________________


More information about the Python-bugs-list mailing list