Reference: Python 2.7.7 Documentation
Reference tool: http://translate.google.cn/
Random Module Learning
First, bookkeeping functions (barely read)
Random.seed ([x]) Initialize the basic random number generator
Random.getstate () Return an object capturing the current internal state of the generator
Random.setstate (state)
Random.jumpahead (N)
Random.getrandbits (k) Returns a python long int with k random bits.
Try it, a long type of 2bit (random value 0-3)
>>> print random.getrandbits (2)
0
Try it, a long type of 2bit (random value 0-3)
Second, ★functions for integers (integer)
Random.randrange (STOP)
Random.randrange (Start, stop[, step])
Random.randint (A, B)
Three, ★functions for sequences (sequence)
Random.choice (SEQ) returns any element of a non-empty sequence
>>> Random.choice ([1, ' Hello ', ' world ')
' Hello '
Random.shuffle (x[, random]) randomly sorts all elements of a sequence
Random.sample (population, k) gets a random fragment of the specified length from the specified sequence. The sample function does not modify the original sequence.
Iv. OMG my probability theory has been returned to the teacher, so many distribution ╮(╯▽╰)╭
★random.random () returns a random floating-point number in [0.0, 1.0].
★random.uniform (A, B) returns the random floating-point number in [A, b]
Random.triangular (low=0.0, high=1.0, Mode=none)
Random.betavariate (alpha, beta) Beta distribution
Random.expovariate (LAMBD) Index distribution
Random.gammavariate (alpha, beta) gamma distribution
Random.gauss (Mu, sigma) Gaussian distribution
Random.lognormvariate (Mu, sigma) Log normal distribution
Random.normalvariate (Mu, sigma) normal distribution normal distribution
Random.vonmisesvariate (Mu, kappa)
Random.paretovariate (Alpha) Pareto distribution
Random.weibullvariate (alpha, beta) Weibull distribution
Python Standard library-random Learning