Author serhiy.storchaka
Recipients Serge Anuchin, mark.dickinson, pitrou, r.david.murray, rhettinger, serhiy.storchaka, skrah, steven.daprano, tim.peters, vstinner
Date 2015-07-12.08:30:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1436689827.61.0.794783046546.issue24567@psf.upfronthosting.co.za>
In-reply-to
Content
> I originally used the {n} approach but it was less clear and it lead to a re-selection rather than undoing the rounding.  That would change the output.

In normal case j is never equal to n. In very rare cases on platforms with double rounding the unpatched code generates an IndexError, and changing this is the purpose of the patch. Re-selection is so good as undoing the rounding.

Please also note that double rounding causes an error not only when int(random() * n) == n. If random() returns 0.5 - 2**-54 and n = 2029*2, the result is different with double rounding and without it. This causes small bias even if IndexError is not raised.
History
Date User Action Args
2015-07-12 08:30:27serhiy.storchakasetrecipients: + serhiy.storchaka, tim.peters, rhettinger, mark.dickinson, pitrou, vstinner, steven.daprano, r.david.murray, skrah, Serge Anuchin
2015-07-12 08:30:27serhiy.storchakasetmessageid: <1436689827.61.0.794783046546.issue24567@psf.upfronthosting.co.za>
2015-07-12 08:30:27serhiy.storchakalinkissue24567 messages
2015-07-12 08:30:27serhiy.storchakacreate