<commit_before># Gamma Random Numbers

> [Gamma][gamma] distributed pseudorandom numbers.


<section class="usage">

## Usage

``` javascript
var gamma = require( '@stdlib/math/base/random/gamma' );
```

#### gamma( alpha, beta )

Returns a pseudorandom number drawn from a [gamma][gamma] distribution with parameters `alpha` (shape parameter) and `beta` (rate parameter).

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

If `alpha <= 0` or `beta <= 0`, the function returns `NaN`.

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

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

If `alpha` or `beta` is `NaN`, the function returns `NaN`.

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

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

#### gamma.factory( \[alpha, beta, \]\[options\] )

Returns a pseudorandom number generator (PRNG) for generating pseudorandom numbers drawn from a [gamma][gamma] distribution.

``` javascript
var rand = gamma.factory();

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

If provided `alpha` and `beta`, the returned generator returns random variates from the specified distribution.

``` javascript
// Draw from Gamma( 1.5, 1.5 ) distribution:
var rand = gamma.factory( 1.5, 1.5 );

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

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

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

``` javascript
var rand = gamma.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.

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

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

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

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

#### gamma.NAME

The generator name.

``` javascript
var name = gamma.NAME;
// returns 'gamma'
```

#### gamma.PRNG

The underlying pseudorandom number generator.

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

#### gamma.SEED

The value used to seed `gamma()`.

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

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

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

</section>

<!-- /.usage -->


<section class="examples">

## Examples

``` javascript
var gamma = require( '@stdlib/math/base/random/gamma' );

var seed;
var rand;
var i;

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

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

</section>

<!-- /.examples -->


---

<section class="references">

## References

* Marsaglia, George, and <NAME>. 2000. "A Simple Method for Generating Gamma Variables." *ACM Transactions on Mathematical Software* 26 (3). New York, NY, USA: ACM: 363–72. doi:[10.1145/358407.358414][@marsaglia:2000a].


</section>

<!-- /.references -->


<section class="links">

[gamma]: https://en.wikipedia.org/wiki/Gamma_distribution

[@marsaglia:2000a]: http://dx.doi.org/10.1145/358407.358414

</section>

<!-- /.links -->
<commit_msg>Rename variable<commit_after># Gamma Random Numbers

> [Gamma][gamma] distributed pseudorandom numbers.


<section class="usage">

## Usage

``` javascript
var gamma = require( '@stdlib/math/base/random/gamma' );
```

#### gamma( alpha, beta )

Returns a pseudorandom number drawn from a [gamma][gamma] distribution with parameters `alpha` (shape parameter) and `beta` (rate parameter).

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

If `alpha <= 0` or `beta <= 0`, the function returns `NaN`.

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

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

If `alpha` or `beta` is `NaN`, the function returns `NaN`.

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

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

#### gamma.factory( \[alpha, beta, \]\[options\] )

Returns a pseudorandom number generator (PRNG) for generating pseudorandom numbers drawn from a [gamma][gamma] distribution.

``` javascript
var rand = gamma.factory();

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

If provided `alpha` and `beta`, the returned generator returns random variates from the specified distribution.

``` javascript
// Draw from Gamma( 1.5, 1.5 ) distribution:
var rand = gamma.factory( 1.5, 1.5 );

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

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

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

``` javascript
var rand = gamma.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.

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

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

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

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

#### gamma.NAME

The generator name.

``` javascript
var str = gamma.NAME;
// returns 'gamma'
```

#### gamma.PRNG

The underlying pseudorandom number generator.

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

#### gamma.SEED

The value used to seed `gamma()`.

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

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

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

</section>

<!-- /.usage -->


<section class="examples">

## Examples

``` javascript
var gamma = require( '@stdlib/math/base/random/gamma' );

var seed;
var rand;
var i;

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

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

</section>

<!-- /.examples -->


---

<section class="references">

## References

* Marsaglia, George, and <NAME>. 2000. "A Simple Method for Generating Gamma Variables." *ACM Transactions on Mathematical Software* 26 (3). New York, NY, USA: ACM: 363–72. doi:[10.1145/358407.358414][@marsaglia:2000a].


</section>

<!-- /.references -->


<section class="links">

[gamma]: https://en.wikipedia.org/wiki/Gamma_distribution

[@marsaglia:2000a]: http://dx.doi.org/10.1145/358407.358414

</section>

<!-- /.links -->

{'fraction_non_alphanumeric': 0.1872796134256236, 'fraction_numerical': 0.041269426668407994, 'mean_word_length': 3.287793952967525, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 49, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7147674', 'n_tokens_mistral': 3019, 'n_tokens_neox': 2612, 'n_words': 867}