# Student's t Random Numbers

Student's t-distributed pseudorandom numbers.

## Usage

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

#### t( v )

Returns a pseudorandom number drawn from a Student's t-distribution with degrees of freedom `v`.

``````var r = t( 2.4 );
// returns <number>
``````

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

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

r = t( NaN );
// returns NaN
``````

#### t.factory( [v, ][options] )

Returns a pseudorandom number generator (PRNG) for generating pseudorandom numbers drawn from a Student's t-distribution.

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

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

If provided `v`, the returned generator returns random variates from the specified distribution.

``````var rand = t.factory( 1.0 );

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

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

If not provided `v`, the returned generator requires that `v` be provided at each invocation.

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

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

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

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

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

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

#### t.NAME

The generator name.

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

#### t.PRNG

The underlying pseudorandom number generator.

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

#### t.SEED

The value used to seed `t()`.

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

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

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

## Examples

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

var seed;
var rand;
var i;

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

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