[Numpy-discussion] error in beta random variate generation

Christopher Fonnesbeck chris at trichech.us
Wed Jan 25 09:23:10 EST 2006


There appears to be a bug in the beta random number
generator in numpy. A 2-parameter beta distribution
has an expected value of a/(a+b). Hence, a beta(1,1)
should have an expected value of 0.5 (since it is the
equivalent of a uniform random variable on [0,1]).
However, numpy gives the following:

In [6]: from numpy.random import beta

In [7]: from numpy import *

In [8]: mean(beta(1,1,size=10000))
Out[8]: 0.33397400928538834

--
Christopher J. Fonnesbeck

Population Ecologist, Marine Mammal Section
Fish & Wildlife Research Institute (FWC)
St. Petersburg, FL

Adjunct Assistant Professor
Warnell School of Forest Resources
University of Georgia
Athens, GA

T: 727.235.5570
E: chris at trichech.us


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2417 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060125/4b57ea73/attachment.bin>


More information about the NumPy-Discussion mailing list