# Lognormal Random Numbers

Lognormal distributed pseudorandom numbers.

## Usage

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

#### lognormal( mu, sigma )

Returns a pseudorandom number drawn from a lognormal distribution with parameters `mu` (location parameter) and `sigma` (scale parameter).

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

If `mu` or `sigma` is `NaN` or `sigma <= 0`, the function returns `NaN`.

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

r = lognormal( NaN, 5.0 );
// returns NaN

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

#### lognormal.factory( [mu, sigma, ][options] )

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

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

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

If provided `mu` and `sigma`, the returned generator returns random variates from the specified distribution.

``````var rand = lognormal.factory( 10.0, 2.0 );

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

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

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

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

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

r = rand( -2.0, 2.0 );
// 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 = lognormal.factory({
'seed': 12345
});

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

rand = lognormal.factory( 1.0, 2.0, {
'seed': 12345
});

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

#### lognormal.NAME

The generator name.

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

#### lognormal.PRNG

The underlying pseudorandom number generator.

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

#### lognormal.SEED

The value used to seed `lognormal()`.

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

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

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

## Examples

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

var seed;
var rand;
var i;

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

// Create a new pseudorandom number generator...
seed = 1234;
rand = lognormal.factory( 5.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 = lognormal.factory( 0.0, 1.0, {
'seed': lognormal.SEED
});
console.log( '\nseed: %d', lognormal.SEED );
for ( i = 0; i < 100; i++ ) {
console.log( rand() );
}
``````