From ca6cdc2c0259b1b74a3f4c2d29a35e76617a3019 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Mon, 13 May 2002 23:40:14 +0000 Subject: [PATCH] Closes SF bug 527139. Moved temp variables inside guard. --- Lib/random.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Lib/random.py b/Lib/random.py index fe25642191e..affa3819a86 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()