diff options
author | Raymond Hettinger <python@rcn.com> | 2002-05-13 23:40:14 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2002-05-13 23:40:14 (GMT) |
commit | ca6cdc2c0259b1b74a3f4c2d29a35e76617a3019 (patch) | |
tree | e49141e9380529ac08656234d921fa282975f8f3 | |
parent | 5359ad63ce1eb4fa176439cde1afe014b142e212 (diff) | |
download | cpython-ca6cdc2c0259b1b74a3f4c2d29a35e76617a3019.zip cpython-ca6cdc2c0259b1b74a3f4c2d29a35e76617a3019.tar.gz cpython-ca6cdc2c0259b1b74a3f4c2d29a35e76617a3019.tar.bz2 |
Closes SF bug 527139. Moved temp variables inside guard.
-rw-r--r-- | Lib/random.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Lib/random.py b/Lib/random.py index fe25642..affa381 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -446,14 +446,9 @@ class Random: def gammavariate(self, alpha, beta): # beta times standard gamma - ainv = _sqrt(2.0 * alpha - 1.0) - return beta * self.stdgamma(alpha, ainv, alpha - LOG4, alpha + ainv) - - def stdgamma(self, alpha, ainv, bbb, ccc): - # ainv = sqrt(2 * alpha - 1) - # bbb = alpha - log(4) - # ccc = alpha + ainv + return beta * self.stdgamma(alpha) + def stdgamma(self, alpha, *args): # *args for Py2.2 compatiblity random = self.random if alpha <= 0.0: raise ValueError, 'stdgamma: alpha must be > 0.0' @@ -464,6 +459,10 @@ class Random: # variables with non-integral shape parameters", # Applied Statistics, (1977), 26, No. 1, p71-74 + ainv = _sqrt(2.0 * alpha - 1.0) + bbb = alpha - LOG4 + ccc = alpha + ainv + while 1: u1 = random() u2 = random() |