time-to-botec/js/node_modules/@stdlib/stats/base/dists/gamma/mgf
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00
..
docs feat: add the node modules 2022-12-03 12:44:49 +00:00
lib feat: add the node modules 2022-12-03 12:44:49 +00:00
package.json feat: add the node modules 2022-12-03 12:44:49 +00:00
README.md feat: add the node modules 2022-12-03 12:44:49 +00:00

Moment-Generating Function

Gamma distribution moment-generating function (MGF).

The moment-generating function for a gamma random variable is

Moment-generating function (MGF) for a gamma distribution.

where alpha is the shape parameter and beta is the rate parameter. For t >= beta, the MGF is not defined.

Usage

var mgf = require( '@stdlib/stats/base/dists/gamma/mgf' );

mgf( t, alpha, beta )

Evaluates the moment-generating function (MGF) for a gamma distribution with parameters alpha (shape parameter) and beta (rate parameter).

var y = mgf( 0.5, 0.5, 1.0 );
// returns ~1.414

y = mgf( 0.1, 1.0, 1.0 );
// returns ~1.111

y = mgf( -1.0, 4.0, 2.0 );
// returns ~0.198

If provided NaN as any argument, the function returns NaN.

var y = mgf( NaN, 1.0, 1.0 );
// returns NaN

y = mgf( 0.0, NaN, 1.0 );
// returns NaN

y = mgf( 0.0, 1.0, NaN );
// returns NaN

If provided t >= beta, the function returns NaN.

var y = mgf( 2.0, 4.0, 1.0 );
// returns NaN

If provided alpha < 0, the function returns NaN.

var y = mgf( 2.0, -0.5, 1.0 );
// returns NaN

If provided beta <= 0, the function returns NaN.

var y = mgf( 2.0, 1.0, 0.0 );
// returns NaN

y = mgf( 2.0, 1.0, -1.0 );
// returns NaN

mgf.factory( alpha, beta )

Return a function for evaluating the MGF of a gamma distribution with parameters alpha (shape parameter) and beta (rate parameter).

var mymgf = mgf.factory( 3.0, 1.5 );

var y = mymgf( 1.0 );
// returns ~27.0

y = mymgf( 0.5 );
// returns ~3.375

Examples

var randu = require( '@stdlib/random/base/randu' );
var mgf = require( '@stdlib/stats/base/dists/gamma/mgf' );

var a;
var b;
var t;
var v;
var i;

for ( i = 0; i < 10; i++ ) {
    t = randu();
    a = randu() * 5.0;
    b = a + (randu() * 5.0);
    v = mgf( t, a, b );
    console.log( 't: %d, a: %d, b: %d, M_X(t;a,b): %d', t.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), v.toFixed( 4 ) );
}