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 <>
The following code raises a ZeroDivisionError:

from random import Random


This raises:, 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)
Date User Action Args
2020-07-28 17:59:09David MacIversetrecipients: + David MacIver
2020-07-28 17:59:09David MacIversetmessageid: <>
2020-07-28 17:59:09David MacIverlinkissue41421 messages
2020-07-28 17:59:08David MacIvercreate