# Weibull Random Numbers

Weibull distributed pseudorandom numbers.

## Usage

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

#### weibull( k, lambda )

Returns a pseudorandom number drawn from a Weibull distribution with scale parameter `k` and shape parameter `lambda`.

``````var r = weibull( 2.0, 5.0 );
// returns <number>
``````

If `k <= 0` or `lambda <= 0`, the function returns `NaN`.

``````var r = weibull( -2.0, 2.0 );
// returns NaN

r = weibull( 2.0, -2.0 );
// returns NaN
``````

If `k` or `lambda` is `NaN`, the function returns `NaN`.

``````var r = weibull( 5.0, NaN );
// returns NaN

r = weibull( NaN, 2.0 );
// returns NaN
``````

#### weibull.factory( [k, lambda, ][options] )

Returns a pseudorandom number generator (PRNG) for generating pseudorandom numbers drawn from a Weibull distribution.

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

var r = rand( 1.5, 1.5 );
// returns <number>
``````

If provided `k` and `lambda`, the returned generator returns random variates from the specified distribution.

``````var rand = weibull.factory( 1.5, 1.5 );

var r = rand();
// returns <number>

r = rand();
// returns <number>
``````

If not provided `k` and `lambda`, the returned generator requires that both parameters be provided at each invocation.

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

var r = rand( 1.0, 1.0 );
// returns <number>

r = rand( 3.14, 2.25 );
// returns <number>
``````

The function accepts the following `options`:

• seed: pseudorandom number generator seed.

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

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

var r = rand( 2.0, 3.0 );
// returns <number>

rand = weibull.factory( 2.0, 3.0, {
'seed': 12345
});

r = rand();
// returns <number>
``````

#### weibull.NAME

The generator name.

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

#### weibull.PRNG

The underlying pseudorandom number generator.

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

#### weibull.SEED

The value used to seed `weibull()`.

``````var rand;
var r;
var i;

// Generate pseudorandom values...
for ( i = 0; i < 100; i++ ) {
r = weibull( 2.0, 2.0 );
}

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

## Examples

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

var seed;
var rand;
var i;

// Generate pseudorandom numbers...
console.log( '\nseed: %d', weibull.SEED );
for ( i = 0; i < 100; i++ ) {
console.log( weibull( 2.0, 2.0 ) );
}

// Create a new pseudorandom number generator...
seed = 1234;
rand = weibull.factory( 6.0, 2.0, {
'seed': seed
});
console.log( '\nseed: %d', seed );
for ( i = 0; i < 100; i++ ) {
console.log( rand() );
}

// Create another pseudorandom number generator using a previous seed...
rand = weibull.factory( 2.0, 2.0, {
'seed': weibull.SEED
});
console.log( '\nseed: %d', weibull.SEED );
for ( i = 0; i < 100; i++ ) {
console.log( rand() );
}
``````