class_docstr: Random number generator base class used by bound module functions.
  
  Used to instantiate instances of Random to get generators that don't
  share state.
  
  Class Random can also be subclassed if you want to use a different basic
  generator of your own devising: in that case, override the following
  methods:  random(), seed(), getstate(), and setstate().
  Optionally, implement a getrandbits() method so that randrange()
  can cover arbitrarily large ranges.
class_docstr_tok: ["Random","number","generator","base","class","used","by","bound","module","functions",".","Used","to","instantiate","instances","of","Random","to","get","generators","that","don't","share","state",".","Class","Random","can","also","be","subclassed","if","you","want","to","use","a","different","basic","generator","of","your","own","devising",":","in","that","case",",","override","the","following","methods",":","random","(",")",",","seed","(",")",",","getstate","(",")",",","and","setstate","(",")",".","Optionally",",","implement","a","getrandbits","(",")","method","so","that","randrange","(",")","can","cover","arbitrarily","large","ranges","."]
docstr: Gamma distribution.  Not the gamma function!
  
  Conditions on the parameters are alpha > 0 and beta > 0.
  
  The probability distribution function is:
  
              x ** (alpha - 1) * math.exp(-x / beta)
    pdf(x) =  --------------------------------------
                math.gamma(alpha) * beta ** alpha
  
  The mean (expected value) and variance of the random variable are:
  
      E[X] = alpha * beta
      Var[X] = alpha * beta ** 2
docstr_tok: ["Gamma","distribution",".","Not","the","gamma","function","!","Conditions","on","the","parameters","are","alpha",">","0","and","beta",">","0",".","The","probability","distribution","function","is",":","x","*","*","(","alpha","-","1",")","*","math.exp","(","-x","\/","beta",")","pdf","(","x",")","=","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","math.gamma","(","alpha",")","*","beta","*","*","alpha","The","mean","(","expected","value",")","and","variance","of","the","random","variable","are",":","E","[","X","]","=","alpha","*","beta","Var","[","X","]","=","alpha","*","beta","*","*","2"]
code: def gammavariate(self, alpha, beta):
      """Gamma distribution.  Not the gamma function!
  
      Conditions on the parameters are alpha > 0 and beta > 0.
  
      The probability distribution function is:
  
                  x ** (alpha - 1) * math.exp(-x / beta)
        pdf(x) =  --------------------------------------
                    math.gamma(alpha) * beta ** alpha
  
      The mean (expected value) and variance of the random variable are:
  
          E[X] = alpha * beta
          Var[X] = alpha * beta ** 2
  
      """
  
      # Warning: a few older sources define the gamma distribution in terms
      # of alpha > -1.0
      if alpha <= 0.0 or beta <= 0.0:
          raise ValueError("gammavariate: alpha and beta must be > 0.0")
  
      random = self.random
      if alpha > 1.0:
          # Uses R.C.H. Cheng, "The generation of Gamma
          # 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 True:
              u1 = random()
              if not 1e-7 < u1 < 0.9999999:
                  continue
              u2 = 1.0 - random()
              v = _log(u1 / (1.0 - u1)) / ainv
              x = alpha * _exp(v)
              z = u1 * u1 * u2
              r = bbb + ccc * v - x
              if r + SG_MAGICCONST - 4.5 * z >= 0.0 or r >= _log(z):
                  return x * beta
  
      elif alpha == 1.0:
          # expovariate(1/beta)
          return -_log(1.0 - random()) * beta
  
      else:
          # alpha is between 0 and 1 (exclusive)
          # Uses ALGORITHM GS of Statistical Computing - Kennedy & Gentle
          while True:
              u = random()
              b = (_e + alpha) / _e
              p = b * u
              if p <= 1.0:
                  x = p ** (1.0 / alpha)
              else:
                  x = -_log((b - p) / alpha)
              u1 = random()
              if p > 1.0:
                  if u1 <= x ** (alpha - 1.0):
                      break
              elif u1 <= _exp(-x):
                  break
          return x * beta
  
imports: from math import log, exp, pi, e, ceil
  from math import sqrt, acos, cos, sin
  from math import tau, floor, isfinite
  from math import lgamma, fabs, log2
  from os import urandom
  from _collections_abc import Sequence
  from operator import index
  from itertools import accumulate, repeat
  from bisect import bisect
  import os
  import _random
label_desc: Use image node_id 25 for calling the Random obj's underlying member method code with example usage: obj.gammavariate(alpha, beta) and returns: unknown, unknown, unknown