Author tim.peters
Recipients mark.dickinson, oscarbenjamin, rhettinger, tim.peters
Date 2020-07-17.02:40:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Thanks! That explanation really helps explain where "geometric distribution" comes from. Although why it keeps taking k'th roots remains a mystery to me ;-)

Speaking of which, the two instances of


are numerically suspect. Better written as


The underlying `pow()` implementation will, in effect, compute log(random()) with extra bits of precision for internal use. Doing log(random()) forces it to use a 53-bit approximation. Not to mention that it's more _obvious_ to write a k'th root as a k'th root.  Note: then the 1/k can be computed once outside the loop.

Perhaps worse is


which should be written


instead.  W is between 0 and 1, and the closer it is to 0 the more its trailing bits are entirely lost in computing 1-W. It's the purpose of log1p to combat this very problem.
Date User Action Args
2020-07-17 02:40:06tim.peterssetrecipients: + tim.peters, rhettinger, mark.dickinson, oscarbenjamin
2020-07-17 02:40:06tim.peterssetmessageid: <>
2020-07-17 02:40:06tim.peterslinkissue41311 messages
2020-07-17 02:40:05tim.peterscreate