# MINSTD Shuffle

A linear congruential pseudorandom number generator (LCG) whose output is shuffled.

## Usage

``````var minstd = require( '@stdlib/random/base/minstd-shuffle' );
``````

#### minstd()

Returns a pseudorandom integer on the interval `[1, 2147483646]`.

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

#### minstd.normalized()

Returns a pseudorandom number on the interval `[0,1)`.

``````var v = minstd.normalized();
// returns <number>
``````

#### minstd.factory( [seed] )

Returns a linear congruential pseudorandom number generator (LCG) whose output is shuffled.

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

By default, a random integer is used to seed the returned generator. To seed the generator, provide an `integer` on the interval `[1, 2147483646]`.

``````var rand = minstd.factory( 1234 );

var v = rand();
// returns 1421600654
``````

#### minstd.NAME

The generator name.

``````var str = minstd.NAME;
// returns 'minstd-shuffle'
``````

#### minstd.SEED

The value used to seed `minstd()`.

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

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

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

#### minstd.MIN

Minimum possible value.

``````var min = minstd.MIN;
// returns 1
``````

#### minstd.MAX

Maximum possible value.

``````var max = minstd.MAX;
// returns 2147483646
``````

## Notes

• Before output from a simple linear congruential generator (LCG) is returned, the output is shuffled using the Bays-Durham algorithm. This additional step considerably strengthens the "randomness quality" of a simple LCG's output.

## Examples

``````var minstd = require( '@stdlib/random/base/minstd-shuffle' );

var seed;
var rand;
var i;

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

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

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

## References

• Park, S. K., and K. W. Miller. 1988. "Random Number Generators: Good Ones Are Hard to Find." Communications of the ACM 31 (10). New York, NY, USA: ACM: 1192–1201. doi:10.1145/63039.63042.
• Bays, Carter, and S. D. Durham. 1976. "Improving a Poor Random Number Generator." ACM Transactions on Mathematical Software 2 (1). New York, NY, USA: ACM: 59–64. doi:10.1145/355666.355670.
• Herzog, T.N., and G. Lord. 2002. Applications of Monte Carlo Methods to Finance and Insurance. ACTEX Publications. https://books.google.com/books?id=vC7I\_gdX-A0C.
• Press, William H., Brian P. Flannery, Saul A. Teukolsky, and William T. Vetterling. 1992. Numerical Recipes in C: The Art of Scientific Computing, Second Edition. Cambridge University Press.