# Module `rnd`

Bindings for interacting with the random number generator.
This module not only allows basic random number generation, but it also
handles more complicated statistical stuff.
Example usage would be:

if rnd.rnd() < 0.5 then -- 50% chance of this happening else -- And 50% chance of this happening end

## Functions

rnd.rnd (x, y) | Gets a random number. |

rnd.sigma () | Creates a number in the one-sigma range [-1:1]. |

rnd.threesigma () | Creates a number in the three-sigma range [-3:3]. |

rnd.twosigma () | Creates a number in the two-sigma range [-2:2]. |

## Functions

**rnd.rnd**(x, y)-
Gets a random number. With no parameters it returns a random float between
0 and 1.
With one parameter it returns a whole number between 0 and that number
(both included). With two parameters it returns a whole number between
both parameters (both included).

### Parameters

- x: First parameter, read description for details.
- y: Second parameter, read description for details.

### Usage

`n = rnd() -- Number in range [0:1].`

`n = rnd(5) -- Number in range [0:5].`

`n = rnd(3,5) -- Number in range [3,5].`

### Return value:

A randomly generated number, read description for details. **rnd.sigma**()-
Creates a number in the one-sigma range [-1:1].
A one sigma range means that it creates a number following the normal distribution
but limited to the 63% quadrant. This means that the number is biased towards 0,
but can become either 1 or -1. It's a fancier way of generating random numbers.

### Usage:

`n = 5.5 + rnd.sigma()/2. -- Creates a number from 5 to 6 slightly biased to 5.5.`

### Return value:

Returns a number from [-1:1] biased slightly towards 0. **rnd.threesigma**()-
Creates a number in the three-sigma range [-3:3].
This function behaves much like its brothers rnd.sigma and rnd.twosigma. The main
difference is that it uses the three-sigma range which is the 99% quadrant. It
will rarely generate numbers outside the [-2:2] range (about 5% of the time) and
create numbers outside of the [-1:1] range about 37% of the time. This can be used
when you want extremes to appear rarely.

### Usage:

`n = 5.5 + rnd.threesigma()/6. -- Creates a number from 5 to 6 totally biased to 5.5.`

### Return value:

Returns a number from [-3:3] biased totally towards 0. **rnd.twosigma**()-
Creates a number in the two-sigma range [-2:2].
This function behaves much like the rnd.sigma function but uses the two-sigma range,
meaning that numbers are in the 95% quadrant and thus are much more random. They are
biased towards 0 and approximately 63% will be within [-1:1]. The rest will be in
either the [-2:-1] range or the [1:2] range.

### Usage:

`n = 5.5 + rnd.twosigma()/4. -- Creates a number from 5 to 6 heavily biased to 5.5.`

### Return value:

Returns a number from [-2:2] biased heavily towards 0.