@stdlib/stats-base-dists-weibull-mgf
v0.3.1
Published
Weibull distribution moment-generating function (MGF).
Downloads
667
Readme
Moment-Generating Function
Weibull distribution moment-generating function (MGF).
The moment-generating function for a Weibull random variable is
where lambda > 0 is the scale paramater and k > 0 is the shape parameter.
Installation
npm install @stdlib/stats-base-dists-weibull-mgfUsage
var mgf = require( '@stdlib/stats-base-dists-weibull-mgf' );mgf( t, k, lambda )
Evaluates the moment-generating function (MGF) for a Weibull distribution with shape parameter k and scale parameter lambda.
var y = mgf( 1.0, 1.0, 0.5);
// returns ~2.0
y = mgf( -1.0, 4.0, 4.0 );
// returns ~0.019If 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 NaNIf provided k <= 0, the function returns NaN.
var y = mgf( 0.2, -1.0, 0.5 );
// returns NaN
y = mgf( 0.2, 0.0, 0.5 );
// returns NaNIf provided lambda <= 0, the function returns NaN.
var y = mgf( 0.2, 0.5, -1.0 );
// returns NaN
y = mgf( 0.2, 0.5, 0.0 );
// returns NaNmgf.factory( k, lambda )
Returns a function for evaluating the moment-generating function of a Weibull distribution with shape parameter k and scale parameter lambda.
var myMGF = mgf.factory( 8.0, 10.0 );
var y = myMGF( 0.8 );
// returns ~3150.149
y = myMGF( 0.08 );
// returns ~2.137Examples
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var EPS = require( '@stdlib/constants-float64-eps' );
var mgf = require( '@stdlib/stats-base-dists-weibull-mgf' );
var opts = {
'dtype': 'float64'
};
var lambda = uniform( 10, EPS, 10.0, opts );
var k = uniform( 10, EPS, 10.0, opts );
var t = uniform( 10, 0.0, 5.0, opts );
logEachMap( 'x: %0.4f, k: %0.4f, λ: %0.4f, M_X(t;k,λ): %0.4f', t, k, lambda, mgf );C APIs
Usage
#include "stdlib/stats/base/dists/weibull/mgf.h"stdlib_base_dists_weibull_mgf( t, k, lambda )
Evaluates the moment-generating function (MGF) for a Weibull distribution with shape parameter k and scale parameter lambda.
double out = stdlib_base_dists_weibull_mgf( 1.0, 1.0, 0.5 );
// returns ~2.0The function accepts the following arguments:
- t:
[in] doubleinput value. - k:
[in] doubleshape parameter. - λ:
[in] doublescale parameter.
double stdlib_base_dists_weibull_mgf( const double t, const double k, const double λ );Examples
#include "stdlib/stats/base/dists/weibull/mgf.h"
#include "stdlib/constants/float64/eps.h"
#include <stdlib.h>
#include <stdio.h>
static double random_uniform( const double min, const double max ) {
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
return min + ( v*(max-min) );
}
int main( void ) {
double lambda;
double k;
double t;
double y;
int i;
for ( i = 0; i < 25; i++ ) {
t = random_uniform( 0.0, 5.0 );
k = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
lambda = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
y = stdlib_base_dists_weibull_mgf( t, k, lambda );
printf( "t: %lf, k: %lf, λ: %lf, M_X(t;k,λ): %lf\n", t, k, lambda, y );
}
}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-2026. The Stdlib Authors.
