use random

Dependencies: math

The random module contains a seedable random number generator, which is adapted from the one used in Quackery, which is itself the 64-bit version of Bob Jenkins’ “A small noncryptographic PRNG” which can be found at https://burtleburtle.net/bob/rand/smallprng.html.

random.seed ( s → )

Seeds the random number generator using the value on top of the stack, which must be coercible to BigInt.

random.01 ( → n )

Returns a random floating point number in the range [0, 1).

random.fbelow ( nr )

Returns a random floating point number in the range [0, n).

random.ibelow ( nr )

Returns a random integer from 0 to n-1.

random.1in ( nt )

Returns true 1/n-th of the time.

random.range ( a bt )

Returns a random integer from a to b-1.

random.choose ( ai )

Returns a random item from the array a.

random.shuffle ( as )

Returns a new array containing the items of a in a random order.

random.sample ( a ns )

Returns a new array containing n randomly selected items of a, without replacement. If n >= the length of a, the returned array will be a shuffled copy of a.

See Also: random.choices

random.choices ( a ns )

Returns a new array containing n randomly selected items of a, with replacement.

See Also: random.sample

random.normaldist ( μ σn )

Returns a number distributed in the standard normal distribution with mean μ and standard deviation σ.

random.expodist ( λn )

Returns a number distributed in the exponential distribution with mean 1/λ.


back to index

docs@04547c7