diff Lib/random.py @ 23443:03dfe7d343db 2.2

Closes SF bug 527139. Moved temp variables inside guard.
author Raymond Hettinger <python@rcn.com>
date Mon, 13 May 2002 23:43:06 +0000
parents d9b71f62814f
children 453e59a472b2
line wrap: on
line diff
--- a/Lib/random.py	Mon May 13 22:39:28 2002 +0000
+++ b/Lib/random.py	Mon May 13 23:43:06 2002 +0000
@@ -443,14 +443,9 @@
 
     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)
+        return beta * self.stdgamma(alpha)
 
-    def stdgamma(self, alpha, ainv, bbb, ccc):
-        # ainv = sqrt(2 * alpha - 1)
-        # bbb = alpha - log(4)
-        # ccc = alpha + ainv
-
+    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'
@@ -461,6 +456,10 @@
             # 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()