Issue 1658430: random.betavariate(-0,5, -0,5) - Python tracker (original) (raw)
I the "Python Library Reference", about random module, I read :
betavariate(alpha, beta) Beta distribution. Conditions on the parameters are alpha > -1 and beta > -1. Returned values range between 0 and 1.
But
import random random.betavariate(-0.5, -0.5) Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.4/random.py", line 575, in betavariate y = self.gammavariate(alpha, 1.) File "/usr/lib/python2.4/random.py", line 458, in gammavariate raise ValueError, 'gammavariate: alpha and beta must be > 0.0' ValueError: gammavariate: alpha and beta must be > 0.0
The documentation is probably inaccurate, because they are two beta distribution usage in the math world: one with alpha and beta >0 (the common one) and the other whit alpha' and beta' > -1 where alpha'=alpha-1 and beta'=beta-1
this could explain the mistake.
Finally, I thing the documentation should specify :
alpha > 0 and beta > 0
The problem exist in Python 2.4.3 and probably in all versions.