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.

classification
Title: random.betavariate(-0,5, -0,5)
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: aspineux, georg.brandl
Priority: normal Keywords:

Created on 2007-02-12 21:45 by aspineux, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg31248 - (view) Author: Alain Spineux (aspineux) Date: 2007-02-12 21:45
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 "<stdin>", 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.


msg31249 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-02-12 23:09
This is already fixed in the development docs. Thanks for reporting it anyway!
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44574
2007-02-12 21:45:40aspineuxcreate