This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author IRomanowska
Recipients IRomanowska, mark.dickinson, rhettinger, tim.peters, xtreak
Date 2019-11-22.11:18:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1574421510.45.0.168411303692.issue38881@roundup.psfhosted.org>
In-reply-to
Content
Hi, 

Many thanks for engaging with this. 
I agree that we should very clearly separate negative weights from zero weights. A negative number is illegal and that's the end of it. However, a zero weight is not illegal, e.g., [0, 0, 0, 0.1] is a legal sequence to pass as weight. 

Raymond, I agree with you that this is conflating incremental preference with zero chance of occurring. From a standard user perspective, if the [0, 0, 0, 0.1] sequence is passed as weights the first three options have a zero probability of selection thus that interpretation (even if in your opinion erroneous) is very likely to happen for most of the users. 

I think we all agree that an output that always chooses the last element of the sequence is not ok. We differ in opinion as to what should happen instead: raising an error or returning a value at random. My arguments for the latter are: 
 - this seems to be the standard for other programming languages (I've checked for R and NetLogo but this should be confirmed by others);
 - a weight sequence [1, 1, 1, 1] is equivalent to [10, 10, 10, 10] so if we don't want to make [0, 0, 0, 0] 'a special case' it should give the same behaviour (equal probability);
 - when a weight sequence is not provided (i.e., there are no odds given) a random selection is made. One can argue that the odds [,,,,] are similar to [0, 0, 0, 0 ]. Perhaps the zero weights option could be pushed into the if-loop of no weights? 

I see the logic of the second solution, i.e., raising an error. It may make it more difficult to catch the issue for those doing simulations but at least it's not giving a wrong result. 
 
As mentioned this is a key algorithm for many scientific applications with predominantly non-computer science users like myself. So please do take into consideration that it will be often used naively. 

Many thanks.
History
Date User Action Args
2019-11-22 11:18:30IRomanowskasetrecipients: + IRomanowska, tim.peters, rhettinger, mark.dickinson, xtreak
2019-11-22 11:18:30IRomanowskasetmessageid: <1574421510.45.0.168411303692.issue38881@roundup.psfhosted.org>
2019-11-22 11:18:30IRomanowskalinkissue38881 messages
2019-11-22 11:18:29IRomanowskacreate