TypeFunction Librarymath.* Return valueNumber RevisionCurrent Public Release (2015.2646) Keywordsrandom, random number See alsomath.randomseed()

Returns a pseudo-random number from a sequence with uniform distribution.

This function is an interface to the simple pseudo-random generator function rand provided by ANSI C. No guarantees can be given for its statistical properties.

There are 3 versions of this function:

- When called without arguments, returns a uniform pseudo-random real number in the range
`[0,1]`

. - When called with an integer number
`m`

,`math.random`

returns a uniform pseudo-random integer in the range`[1,m]`

. - When called with two integer numbers
`m`

and`n`

,`math.random`

returns a uniform pseudo-random integer in the range`[m,n]`

.

Note

The random number generator should typically be seeded with math.randomseed() before this function is called.

```
math.random()
math.random( m )
math.random( m, n )
```

*Number.* A number.

*Number.* A number.

```
print(math.random()) --> a number between 0 and 1
print(math.random()) --> another number between 0 and 1
print(math.random(10)) --> an integer between 1 and 10 (inclusive)
print(math.random(70, 80)) --> an integer between 70 and 80 (inclusive)
```