Tools
Pseudorandom number generator (PRNG) array creation function tools.
Usage
var ns = require( '@stdlib/random/array/tools' );
ns
Namespace containing array creation pseudorandom number generator (PRNG) function tools.
var o = ns;
// returns {...}
The namespace contains the following:
binaryFactory( prng, dtypes, dtype )
: create a factory function for generating pseudorandom values drawn from a binary PRNG.binary( prng, dtypes, dtype )
: constructor for creating arrays filled with pseudorandom values drawn from a binary PRNG.nullary( prng, dtypes, dtype )
: constructor for creating arrays filled with pseudorandom values drawn from a nullary PRNG.ternaryFactory( prng, dtypes, dtype )
: create a factory function for generating pseudorandom values drawn from a ternary PRNG.ternary( prng, dtypes, dtype )
: constructor for creating arrays filled with pseudorandom values drawn from a ternary PRNG.unaryFactory( prng, dtypes, dtype )
: create a factory function for generating pseudorandom values drawn from a unary PRNG.unary( prng, dtypes, dtype )
: constructor for creating arrays filled with pseudorandom values drawn from a unary PRNG.
Examples
var exponential = require( '@stdlib/random/base/exponential' );
var arcsine = require( '@stdlib/random/base/arcsine' );
var randn = require( '@stdlib/random/base/improved-ziggurat' );
var ns = require( '@stdlib/random/array/tools' );
// Create a binary PRNG array:
var dtypes = [ 'float64', 'float32', 'generic' ];
var defaultDType = 'float64';
var rand = new ns.binary( arcsine, dtypes, defaultDType );
var x = rand.generate( 10, 2.0, 5.0 );
// e.g., returns <Float64Array>[ ~3.65, ~4.34, ~3.52, ~4.68, ~2.62, ... ]
// Create a unary PRNG array:
rand = new ns.unary( exponential, dtypes, defaultDType );
x = rand.generate( 10, 0.5 );
// e.g., returns <Float64Array>[ ~0.22, ~2.89, ~0.69, ~2.48, ~0.82, ... ]
// Create a nullary PRNG array:
rand = new ns.nullary( randn, dtypes, defaultDType );
x = rand.generate( 10 );
// e.g., returns <Float64Array>[ ~-0.22, ~1.89, ~-0.69, ~0.48, ~-0.82, ... ]