[ python-Bugs-1658430 ] random.betavariate(-0,5, -0,5)

SourceForge.net noreply at sourceforge.net
Tue Feb 13 00:09:53 CET 2007


Bugs item #1658430, was opened at 2007-02-12 21:45
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1658430&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
>Status: Closed
>Resolution: Duplicate
Priority: 5
Private: No
Submitted By: Alain Spineux (aspineux)
Assigned to: Nobody/Anonymous (nobody)
Summary: random.betavariate(-0,5, -0,5) 

Initial Comment:

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.




----------------------------------------------------------------------

>Comment By: Georg Brandl (gbrandl)
Date: 2007-02-12 23:09

Message:
Logged In: YES 
user_id=849994
Originator: NO

This is already fixed in the development docs. Thanks for reporting it
anyway!

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1658430&group_id=5470


More information about the Python-bugs-list mailing list