time-to-botec/js/node_modules/@stdlib/stats/base/dists/triangular/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

Triangular distribution moment-generating function (MGF).

The moment-generating function for a triangular random variable is

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

where a is the lower limit, b is the upper limit, and c is the mode of the distribution. The parameters must satisfy b > a and a <= b <= c.

Usage

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

mgf( t, a, b, c )

Evaluates the moment-generating function (MGF) for a triangular distribution with parameters a (lower limit), b (upper limit), and c (mode).

var y = mgf( 0.5, -1.0, 1.0, 0.0 );
// returns ~1.021

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

y = mgf( -0.3, -20.0, 0.0, -2.0 );
// returns ~24.334

y = mgf( -2.0, -1.0, 1.0, 0.0 );
// returns ~1.381

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

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

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

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

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

If provided parameters not satisfying a <= c <= b, the function returns NaN.

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

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

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

mgf.factory( a, b, c )

Returns a function for evaluating the moment-generating function of a triangular distribution with parameters a (lower limit), b (upper limit), and c (mode).

var mymgf = mgf.factory( 0.0, 2.0, 1.0 );

var y = mymgf( -1.0 );
// returns ~0.3996

y = mymgf( 2.0 );
// returns ~10.205

Examples

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

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

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