Random number generation in Python
The Python module random contains functions for generating random numbers
according to several common distributions.
| Distribution | Python function(s) |
| Uniform | random(), uniform(a, b) |
| Beta | betavariate(alpha, beta) |
| Exponential | expovariate(lambda) |
| Gamma | gammavariate(alpha, beta) |
| Normal | gauss(mean, sigma), normalvariate(mean, sigma) |
| Lognormal | lognormalvariate(mu, sigma) |
| Pareto | paretovariate(alpha) |
There are, however, a few common distributions not on the list above. Code is available here for the following distributions.
SciPy has a large collection of random number generation functions as methods on distribution objects. See Distributions in SciPy.
See also:
Distribution
chart
Stand-alone numerical code