rand
Module rand provides pseudo-random number generation.
As with the Go math/rand (opens in a new tab) package on which it is based, this module is not safe for use for security-sensitive applications.
Functions
float
Function signature
float() floatReturns a random float between 0 and 1.
Example
>>> rand.float()
0.44997274093073925int
Function signature
int() intReturns a non-negative pseudo-random 64 bit integer.
Example
>>> rand.int()
1667297659146365586intn
Function signature
intn(n int) intReturns a non-negative pseudo-random 64 bit integer in the range [0, n).
Example
>>> rand.intn(10)
7norm_float
Function signature
norm_float() floatReturns a normally distributed float in the range [-math.MaxFloat64, +math.MaxFloat64] with standard normal distribution (mean = 0, stddev = 1).
Example
>>> rand.norm_float()
0.44997274093073925exp_float
Function signature
exp_float() floatReturns an exponentially distributed float in the range (0, +math.MaxFloat64] with an exponential distribution whose rate parameter (lambda) is 1 and whose mean is 1/lambda (1).
Example
>>> rand.exp_float()
0.17764313580968902shuffle
Function signature
shuffle(list)Shuffles a list in place and returns it.
Example
>>> l := [1, 2, 3, 4, 5]
>>> rand.shuffle(l)
[3, 1, 5, 4, 2]