...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
#include <boost/math/distributions/inverse_gaussian.hpp>
namespace boost{ namespace math{ template <class RealType = double, class Policy = policies::policy<> > class inverse_gaussian_distribution { public: typedef RealType value_type; typedef Policy policy_type; inverse_gaussian_distribution(RealType mean = 1, RealType scale = 1); RealType mean()const; // mean default 1. RealType scale()const; // Optional scale, default 1 (unscaled). RealType shape()const; // Shape = scale/mean. }; typedef inverse_gaussian_distribution<double> inverse_gaussian; }} // namespace boost // namespace math
The Inverse Gaussian distribution distribution is a continuous probability distribution.
The distribution is also called 'normalinverse Gaussian distribution', and 'normal Inverse' distribution.
It is also convenient to provide unity as default for both mean and scale. This is the Standard form for all distributions. The Inverse Gaussian distribution was first studied in relation to Brownian motion. In 1956 M.C.K. Tweedie used the name Inverse Gaussian because there is an inverse relationship between the time to cover a unit distance and distance covered in unit time. The inverse Gaussian is one of family of distributions that have been called the Tweedie distributions.
(So inverse in the name may mislead: it does not relate to the inverse of a distribution).
The tails of the distribution decrease more slowly than the normal distribution. It is therefore suitable to model phenomena where numerically large values are more probable than is the case for the normal distribution. For stock market returns and prices, a key characteristic is that it models that extremely large variations from typical (crashes) can occur even when almost all (normal) variations are small.
Examples are returns from financial assets and turbulent wind speeds.
The normalinverse Gaussian distributions form a subclass of the generalised hyperbolic distributions.
See distribution. Weisstein, Eric W. "Inverse Gaussian Distribution." From MathWorldA Wolfram Web Resource.
If you want a double
precision
inverse_gaussian distribution you can use
boost::math::inverse_gaussian_distribution<>
or, more conveniently, you can write
using boost::math::inverse_gaussian; inverse_gaussian my_ig(2, 3);
For mean parameters μ and scale (also called precision) parameter λ, and random variate x, the inverse_gaussian distribution is defined by the probability density function (PDF):
f(x;μ, λ) = √(λ/2πx^{3}) e^{λ(xμ)²/2μ²x}
and Cumulative Density Function (CDF):
F(x;μ, λ) = Φ{√(λx) (xμ1)} + e^{2μ/λ} Φ{√(λ/μ) (1+x/μ)}
where Φ is the standard normal distribution CDF.
The following graphs illustrate how the PDF and CDF of the inverse_gaussian distribution varies for a few values of parameters μ and λ:
Tweedie also provided 3 other parameterisations where (μ and λ) are replaced by their ratio φ = λ/μ and by 1/μ: these forms may be more suitable for Bayesian applications. These can be found on Seshadri, page 2 and are also discussed by Chhikara and Folks on page 105. Another related parameterisation, the __wald_distrib (where mean μ is unity) is also provided.
inverse_gaussian_distribution(RealType df = 1, RealType scale = 1); // optionally scaled.
Constructs an inverse_gaussian distribution with μ mean, and scale λ, with both default values 1.
Requires that both the mean μ parameter and scale λ are greater than zero, otherwise calls domain_error.
RealType mean()const;
Returns the mean μ parameter of this distribution.
RealType scale()const;
Returns the scale λ parameter of this distribution.
All the usual nonmember accessor functions that are generic to all distributions are supported: Cumulative Distribution Function, Probability Density Function, Quantile, Hazard Function, Cumulative Hazard Function, mean, median, mode, variance, standard deviation, skewness, kurtosis, kurtosis_excess, range and support.
The domain of the random variate is [0,+∞).
Note  

Unlike some definitions, this implementation supports a random variate equal to zero as a special case, returning zero for both pdf and cdf. 
The inverse_gaussian distribution is implemented in terms of the exponential function and standard normal distribution N0,1 Φ : refer to the accuracy data for those functions for more information. But in general, gamma (and thus inverse gamma) results are often accurate to a few epsilon, >14 decimal digits accuracy for 64bit double.
In the following table μ is the mean parameter and λ is the scale parameter of the inverse_gaussian distribution, x is the random variate, p is the probability and q = 1p its complement. Parameters μ for shape and λ for scale are used for the inverse gaussian function.
Function 
Implementation Notes 


√(λ/ 2πx^{3}) e^{λ(x  μ)²/ 2μ²x} 
cdf 
Φ{√(λx) (xμ1)} + e^{2μ/λ} Φ{√(λ/μ) (1+x/μ)} 
cdf complement 
using complement of Φ above. 
quantile 
No closed form known. Estimated using a guess refined by NewtonRaphson iteration. 
quantile from the complement 
No closed form known. Estimated using a guess refined by NewtonRaphson iteration. 
mode 
μ {√(1+9μ²/4λ²)²  3μ/2λ} 
median 
No closed form analytic equation is known, but is evaluated as quantile(0.5) 
mean 
μ 
variance 
μ³/λ 
skewness 
3 √ (μ/λ) 
kurtosis_excess 
15μ/λ 
kurtosis 
12μ/λ 