@stdlib/stats-base-dists-rayleigh-mgf
v0.2.2
Published
Rayleigh distribution moment-generating function (MGF).
Downloads
290
Readme
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.
Installation
npm install @stdlib/stats-base-dists-rayleigh-mgf
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 ) );
}
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.