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
( n
→ r
)Returns a random floating point number in the range [0, n
).
random.ibelow
( n
→ r
)Returns a random integer from 0 to n
-1.
random.1in
( n
→ t
)Returns true 1/n
-th of the time.
random.range
( a
b
→ t
)Returns a random integer from a
to b
-1.
random.choose
( a
→ i
)Returns a random item from the array a
.
random.shuffle
( a
→ s
)Returns a new array containing the items of a
in a random order.
random.sample
( a
n
→ s
)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
n
→ s
)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/λ
.
docs@04547c7