[Patches] A bug fix to betavariate() in random.py
Janne Sinkkonen
janne@nnets.fi
31 May 2000 13:34:05 +0300
Guido van Rossum <guido@python.org> writes:
> But it seems to do the following:
>
> def beta(a, b):
> x1 = gamma(a)
> if x1 == 0.0: return 0.0
> else: return x1/(x1+gamma(b))
>
> meaning it returns y/(y+z) where you return z/(y+z); it also tests for
> zero where you don't.
My mistake. Although it is symmetric so that y/(y+z) vs. z/(y+z)
essentially swaps the arguments, what you have above seems to be
the convention.
> Do you have the actual *text* of the Devroye algorithm that you quote?
No. I have the matlab code which refers to Devroye, and
Gelman, A. et al. (1995) Bayesian data analysis, p. 481. (They also
use the arguments like the code above.)
--
Janne