# Module `rng`

T-Engine random number generator API Uses the SIMD oriented Fast Mersenne Twister.

## Functions

 avg (min, max, size) The average of several repeated calls to the range function. chance (odds) Decide if a one in X chance occurs. dice (rolls, sides) The sum of a series of dice rolls. float (min, max) Select a random floating point number from a uniform distribution. normal (mean, stdev) Select an integer from a normal distribution. normalFloat (mean, stdev) Select a floating point number from a normal distribution. percent (success) Decide if something should occur based on a percent chance. range (min, max) Select a random integer from a uniform distribution. seed (new_seed) Set the seed for the random number generator.

## Functions

avg (min, max, size)
The average of several repeated calls to the range function.

### Parameters

• min: The lower limit of the distribution.
• max: The upper limir of the distribution.
• size: The number of samples (default 2).

### Return value:

The average from size samples.

chance (odds)
Decide if a one in X chance occurs.

### Parameters

• odds: The X in "1 in X". As the X increases, the odds of success decrease accordingly, with a 100/X% chance of returning true.

### Return value:

A boolean representing success.
dice (rolls, sides)
The sum of a series of dice rolls.

### Parameters

• rolls: The number of rolls of dice to simulate. (3 in 3d6)
• sides: How many sides the dice has. (6 in 3d6)

### Return value:

The sum of the dice rolls.
float (min, max)
Select a random floating point number from a uniform distribution.

### Parameters

• min: The lower limit of the distribution.
• max: The upper limit of the distribution.

### Return value:

The randomly selected number.
normal (mean, stdev)
Select an integer from a normal distribution.

### Parameters

• mean: The mean of the normal distribution
• stdev: The standard deviation of the normal distribution.

### Return value:

The selected integer.

normalFloat (mean, stdev)
Select a floating point number from a normal distribution. Uses the Box-Muller transform.

### Parameters

• mean: The mean of the normal distribution
• stdev: The standard deviation of the normal distribution.

### Return value:

The selected floating point number.

percent (success)
Decide if something should occur based on a percent chance.

### Parameters

• success: The percent chance (0-100) to return true.

### Return value:

A boolean representing success.
range (min, max)
Select a random integer from a uniform distribution.

### Parameters

• min: The lower limit of the distribution.
• max: The upper limit of the distribution.

### Return value:

The randomly selected integer.
seed (new_seed)
Set the seed for the random number generator. The RNG will be re-initialized after setting the seed.

### Parameters

• new_seed: The new seed, unless the number is negative in which case the clock time will be used.