About stdlib...
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
Logistic distribution moment-generating function (MGF).
The moment-generating function for a logistic random variable is
for st ∈ (-1,1), where mu is the location parameter and s is the scale parameter. In above equation, B denotes the Beta function. For st outside the interval (-1,1), the function is not defined.
To use in Observable,
mgf = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/stats-base-dists-logistic-mgf@umd/browser.js' )To vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:
var mgf = require( 'path/to/vendor/umd/stats-base-dists-logistic-mgf/index.js' )To include the bundle in a webpage,
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/stdlib-js/stats-base-dists-logistic-mgf@umd/browser.js"></script>If no recognized module system is present, access bundle contents via the global scope:
<script type="text/javascript"> (function () { window.mgf; })(); </script>Evaluates the logarithm of the moment-generating function (MGF) for a logistic distribution with parameters mu (location parameter) and s (scale parameter).
var y = mgf( 0.9, 0.0, 1.0 ); // returns ~9.15 y = mgf( 0.1, 4.0, 4.0 ); // returns ~1.971 y = mgf( -0.2, 4.0, 4.0 ); // returns ~1.921If provided NaN as any argument, the function returns NaN.
var y = mgf( NaN, 0.0, 1.0 ); // returns NaN y = mgf( 0.0, NaN, 1.0 ); // returns NaN y = mgf( 0.0, 0.0, NaN ); // returns NaNIf provided s < 0 or abs( s * t ) > 1, the function returns NaN.
var y = mgf( 0.5, 0.0, -1.0 ); // returns NaN y = mgf( 0.5, 0.0, 4.0 ); // returns NaNReturns a function for evaluating the moment-generating function (MGF) of a logistic distribution with parameters mu (location parameter) and s (scale parameter).
var mymgf = mgf.factory( 10.0, 0.5 ); var y = mymgf( 0.5 ); // returns ~164.846 y = mymgf( 2.0 ); // returns Infinity<!DOCTYPE html> <html lang="en"> <body> <script type="text/javascript" src="https://cdn.jsdelivr.net/gh/stdlib-js/random-array-uniform@umd/browser.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/gh/stdlib-js/console-log-each-map@umd/browser.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/gh/stdlib-js/stats-base-dists-logistic-mgf@umd/browser.js"></script> <script type="text/javascript"> (function () { var opts = { 'dtype': 'float64' }; var t = uniform( 10, 0.0, 1.0, opts ); var mu = uniform( 10, -5.0, 5.0, opts ); var s = uniform( 10, 0.0, 2.0, opts ); logEachMap( 't: %0.4f, µ: %0.4f, s: %0.4f, M_X(t;µ,s): %0.4f', t, mu, s, mgf ); })(); </script> </body> </html>#include "stdlib/stats/base/dists/logistic/mgf.h"Evaluates the logarithm of the moment-generating function (MGF) for a logistic distribution with parameters mu (location parameter) and s (scale parameter).
double out = stdlib_base_dists_logistic_mgf( 0.9, 0.0, 1.0 ); // returns ~9.15The function accepts the following arguments:
- t:
[in] doubleinput value. - mu:
[in] doublelocation parameter. - s:
[in] doublescale parameter.
double stdlib_base_dists_logistic_mgf( const double t, const double mu, const double s );#include "stdlib/stats/base/dists/logistic/mgf.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 mu; double s; double t; double y; int i; for ( i = 0; i < 25; i++ ) { mu = random_uniform( -5.0, 5.0 ); s = random_uniform( 0.0, 20.0 ); t = random_uniform( 0.0, 10.0 ); y = stdlib_base_dists_logistic_mgf( t, mu, s ); printf( "t: %lf, µ: %lf, s: %lf, M_X(t;µ,s): %lf\n", t, mu, s, y ); } }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.
See LICENSE.
Copyright © 2016-2025. The Stdlib Authors.