random
Jump to navigation
Jump to search
Returns a random number within the specified interval.
rand = math.random([ [low, ] high]) rand = random([ [low, ] high])
Arguments
- low
- number - lower integer limit on the returned random value.
- high
- number - upper integer limit on the returned random value.
Returns
- rand
- number - Generated random value. If no arguments were specified, the value is a uniformly-distributed decimal between 0 (inclusive) and 1 (exclusive). Otherwise, returns a uniformly-distributed integer between
low
(1 if not specified) andhigh
, both bounds inclusive.
See also
Patch changes
Patch 5.4.2 (2013-12-10): The random
and math.random
functions now use the securerandom
RNG added in 5.4.0. The standard library-derived random number generator is available as fastrandom.