# randi

Pseudorandom numbers having integer values.

## Usage

``````var randi = require( '@stdlib/random/base/randi' );
``````

#### randi()

Returns a pseudorandom number having an integer value.

``````var v = randi();
// returns <number>
``````

#### randi.factory( [options] )

Returns a pseudorandom number generator (PRNG) for generating random numbers.

``````var rand = randi.factory();
``````

The function accepts the following `options`:

• name: name of a supported pseudorandom number generator (PRNG), which will serve as the underlying source of pseudorandom numbers. Default: `'minstd-shuffle'`.
• seed: pseudorandom number generator seed.

By default, the underlying pseudorandom number generator is `minstd-shuffle`. To use a different PRNG, set the `name` option.

``````var rand = randi.factory({
'name': 'minstd'
});

var v = rand();
// returns <number>
``````

To seed a pseudorandom number generator, set the `seed` option.

``````var rand = randi.factory({
'seed': 12345
});

var v = rand();
// returns <number>
``````

#### randi.NAME

The generator name.

``````var str = randi.NAME;
// returns 'randi'
``````

#### randi.PRNG

The underlying pseudorandom number generator.

``````var prng = randi.PRNG;
// returns <Function>
``````

#### randi.SEED

The value used to seed `randi()`.

``````var rand;
var v;
var i;

// Generate pseudorandom values...
for ( i = 0; i < 100; i++ ) {
v = randi();
}

// Generate the same pseudorandom values...
rand = randi.factory({
'seed': randi.SEED
});
for ( i = 0; i < 100; i++ ) {
v = rand();
}
``````

#### randi.MIN

Minimum value lower bound (specific to underlying PRNG).

``````var min = randi.MIN;
// returns <number>
``````

#### randi.MAX

Maximum value upper bound (specific to underlying PRNG).

``````var max = randi.MAX;
// returns <number>
``````

## Notes

• Warning: the default underlying source of pseudorandom numbers may change in the future. If exact reproducibility is required, either explicitly specify a PRNG via the `name` option or use an underlying PRNG directly.

## Examples

``````var randi = require( '@stdlib/random/base/randi' );

var seed;
var rand;
var i;

// Generate pseudorandom numbers...
for ( i = 0; i < 100; i++ ) {
console.log( randi() );
}

// Create a new pseudorandom number generator...
seed = 1234;
rand = randi.factory({
'seed': seed
});
for ( i = 0; i < 100; i++ ) {
console.log( rand() );
}

// Create another pseudorandom number generator using a previous seed...
rand = randi.factory({
'seed': randi.SEED
});
for ( i = 0; i < 100; i++ ) {
console.log( rand() );
}
``````