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 David MacIver
Recipients David MacIver
Date 2020-07-28.17:59:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1595959149.08.0.339696183777.issue41421@roundup.psfhosted.org>
In-reply-to
Content
The following code raises a ZeroDivisionError:


from random import Random

Random(14064741636871487939).paretovariate(0.01)


This raises:

random.py, line 692, in paretovariate
    return 1.0 / u ** (1.0/alpha)
ZeroDivisionError: float division by zero


That specific stack trace is from 3.8.5 but I've tried this on 3.6 and 3.7 as well.

It's a little hard to tell what the intended correct range of parameter values is for paretovariate, and this may just be lack of validation for the alpha < 1 case - perhaps that was never intended to be supported?

Based on some very informal inspection, what seems to happen is that the probability of getting a ZeroDivisionError approaches one as you approach zero. They rarely occur at this level of alpha (0.01), but for alpha=0.001 they seem to occur just under half the time, and for alpha=0.0001 they occur more than 90% of the time.

(For the interested, this bug was found by Hypothesis as part of its own testing of our integration with the Random API)
History
Date User Action Args
2020-07-28 17:59:09David MacIversetrecipients: + David MacIver
2020-07-28 17:59:09David MacIversetmessageid: <1595959149.08.0.339696183777.issue41421@roundup.psfhosted.org>
2020-07-28 17:59:09David MacIverlinkissue41421 messages
2020-07-28 17:59:08David MacIvercreate