Moment-Generating Function

Rayleigh distribution moment-generating function (MGF).

The moment-generating function for a Rayleigh random variable is

upper M Subscript upper X Baseline left-parenthesis t right-parenthesis colon equals double-struck upper E left-bracket e Superscript t upper X Baseline right-bracket equals 1 plus sigma t e Superscript sigma squared t squared slash 2 Baseline StartRoot StartFraction pi Over 2 EndFraction EndRoot left-parenthesis erf left-parenthesis StartFraction sigma t Over StartRoot 2 EndRoot EndFraction right-parenthesis plus 1 right-parenthesis

where sigma > 0 is the scale parameter.

Usage

var mgf = require( '@stdlib/math/base/dists/rayleigh/mgf' );

mgf( t, sigma )

Evaluates the moment-generating function for a Rayleigh distribution with scale parameter sigma.

var y = mgf( 1.0, 3.0 );
// returns ~678.508

y = mgf( 1.0, 2.0 );
// returns ~38.65

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

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

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

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

If provided sigma < 0, the function returns NaN.

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

mgf.factory( sigma )

Returns a function for evaluating the moment-generating function of a Rayleigh distribution with parameter sigma (scale parameter).

var myMGF = mgf.factory( 0.5 );
var y = myMGF( 1.0 );
// returns ~2.715

y = myMGF( 0.5 );
// returns ~1.888

Examples

var randu = require( '@stdlib/random/base/randu' );
var mgf = require( '@stdlib/math/base/dists/rayleigh/mgf' );

var sigma;
var t;
var y;
var i;

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