Inverse gamma distribution cumulative distribution function (CDF).
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!
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url]
[Inverse Gamma][inverse-gamma] distribution [cumulative distribution function][cdf].
math
F(x; \alpha, \beta) = \frac{\Gamma\left(\alpha,\frac{\beta}{x}\right)}{\Gamma(\alpha)} = Q\left(\frac{\beta}{x},\alpha\right)alpha > 0 is the shape parameter and beta > 0 is the scale parameter. Q is the upper regularized incomplete gamma function.bash
npm install @stdlib/stats-base-dists-invgamma-cdfscript tag without installation and bundlers, use the [ES Module][es-module] available on the [esm][esm-url] branch (see [README][esm-readme]).deno][deno-url] branch (see [README][deno-readme] for usage intructions).umd][umd-url] branch (see [README][umd-readme]).javascript
var cdf = require( '@stdlib/stats-base-dists-invgamma-cdf' );alpha (shape parameter) and beta (rate parameter).javascript
var y = cdf( 2.0, 1.0, 1.0 );
// returns ~0.607
y = cdf( 2.0, 3.0, 1.0 );
// returns ~0.986
y = cdf( -1.0, 2.0, 2.0 );
// returns 0.0
y = cdf( -Infinity, 4.0, 2.0 );
// returns 0.0
y = cdf( +Infinity, 4.0, 2.0 );
// returns 1.0NaN as any argument, the function returns NaN.javascript
var y = cdf( NaN, 1.0, 1.0 );
// returns NaN
y = cdf( 0.0, NaN, 1.0 );
// returns NaN
y = cdf( 0.0, 1.0, NaN );
// returns NaNalpha <= 0, the function returns NaN.javascript
var y = cdf( 2.0, -1.0, 0.5 );
// returns NaNbeta <= 0, the function returns NaN.javascript
var y = cdf( 2.0, 0.5, -1.0 );
// returns NaNalpha (shape parameter) and beta (rate parameter).javascript
var mycdf = cdf.factory( 0.5, 0.1 );
var y = mycdf( 12.0 );
// returns ~0.897
y = mycdf( 8.0 );
// returns ~0.874c
#include "stdlib/stats/base/dists/invgamma/cdf.h"alpha (shape parameter) and beta (scale parameter).c
double out = stdlib_base_dists_invgamma_cdf( 2.0, 1.0, 1.0 );
// returns ~0.607
out = stdlib_base_dists_invgamma_cdf( 2.0, 3.0, 1.0 );
// returns ~0.986[in] double input value.[in] double shape parameter.[in] double scale parameter.c
double stdlib_base_dists_invgamma_cdf( const double x, const double alpha, const double beta );c
#include "stdlib/stats/base/dists/invgamma/cdf.h"
#include <stdlib.h>
#include <stdio.h>
static double random_uniform( double min, double max ) {
double scale = rand() / (double) RAND_MAX;
return min + ( scale * ( max - min ) );
}
int main( void ) {
double alpha;
double beta;
double x;
double y;
int i;
for ( i = 0; i < 25; i++ ) {
x = random_uniform( 0.1, 5.0 );
alpha = random_uniform( 1.0, 5.0 );
beta = random_uniform( 1.0, 5.0 );
y = stdlib_base_dists_invgamma_cdf( x, alpha, beta );
printf( "x: %lf, α: %lf, β: %lf, F(x;α,β): %lf\n", x, alpha, beta, y );
}
}javascript
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var cdf = require( '@stdlib/stats-base-dists-invgamma-cdf' );
var opts = {
'dtype': 'float64'
};
var x = uniform( 10, 0.0, 2.0, opts );
var alpha = uniform( 10, 0.0, 5.0, opts );
var beta = uniform( 10, 0.0, 5.0, opts );
logEachMap( 'x: %0.4f, α: %0.4f, β: %0.4f, F(x;α,β): %0.4f', x, alpha, beta, cdf );