|
||
---|---|---|
.. | ||
docs | ||
lib | ||
package.json | ||
README.md |
Moment-Generating Function
Rayleigh distribution moment-generating function (MGF).
The moment-generating function for a Rayleigh random variable is
where sigma > 0
is the scale parameter.
Usage
var mgf = require( '@stdlib/stats/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/stats/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 ) );
}