3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Inverse Gaussian (or Inverse Normal) Distribution</title>
5 <link rel="stylesheet" href="../../../math.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../../index.html" title="Math Toolkit 2.11.0">
8 <link rel="up" href="../dists.html" title="Distributions">
9 <link rel="prev" href="inverse_gamma_dist.html" title="Inverse Gamma Distribution">
10 <link rel="next" href="laplace_dist.html" title="Laplace Distribution">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <a accesskey="p" href="inverse_gamma_dist.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="laplace_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h4 class="title">
27 <a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist"></a><a class="link" href="inverse_gaussian_dist.html" title="Inverse Gaussian (or Inverse Normal) Distribution">Inverse
28 Gaussian (or Inverse Normal) Distribution</a>
29 </h4></div></div></div>
30 <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">distributions</span><span class="special">/</span><span class="identifier">inverse_gaussian</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
31 <pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
33 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">RealType</span> <span class="special">=</span> <span class="keyword">double</span><span class="special">,</span>
34 <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 20. Policies: Controlling Precision, Error Handling etc">Policy</a> <span class="special">=</span> <a class="link" href="../../pol_ref/pol_ref_ref.html" title="Policy Class Reference">policies::policy<></a> <span class="special">></span>
35 <span class="keyword">class</span> <span class="identifier">inverse_gaussian_distribution</span>
36 <span class="special">{</span>
37 <span class="keyword">public</span><span class="special">:</span>
38 <span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
39 <span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
41 <span class="identifier">inverse_gaussian_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">mean</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">scale</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
43 <span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// mean default 1.</span>
44 <span class="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// Optional scale, default 1 (unscaled).</span>
45 <span class="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// Shape = scale/mean.</span>
46 <span class="special">};</span>
47 <span class="keyword">typedef</span> <span class="identifier">inverse_gaussian_distribution</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">inverse_gaussian</span><span class="special">;</span>
49 <span class="special">}}</span> <span class="comment">// namespace boost // namespace math</span>
52 The Inverse Gaussian distribution distribution is a continuous probability
56 The distribution is also called 'normal-inverse Gaussian distribution',
57 and 'normal Inverse' distribution.
60 It is also convenient to provide unity as default for both mean and scale.
61 This is the Standard form for all distributions. The Inverse Gaussian distribution
62 was first studied in relation to Brownian motion. In 1956 M.C.K. Tweedie
63 used the name Inverse Gaussian because there is an inverse relationship
64 between the time to cover a unit distance and distance covered in unit
65 time. The inverse Gaussian is one of family of distributions that have
66 been called the <a href="http://en.wikipedia.org/wiki/Tweedie_distributions" target="_top">Tweedie
70 (So <span class="emphasis"><em>inverse</em></span> in the name may mislead: it does <span class="bold"><strong>not</strong></span> relate to the inverse of a distribution).
73 The tails of the distribution decrease more slowly than the normal distribution.
74 It is therefore suitable to model phenomena where numerically large values
75 are more probable than is the case for the normal distribution. For stock
76 market returns and prices, a key characteristic is that it models that
77 extremely large variations from typical (crashes) can occur even when almost
78 all (normal) variations are small.
81 Examples are returns from financial assets and turbulent wind speeds.
84 The normal-inverse Gaussian distributions form a subclass of the generalised
85 hyperbolic distributions.
88 See <a href="http://en.wikipedia.org/wiki/Normal-inverse_Gaussian_distribution" target="_top">distribution</a>.
89 <a href="http://mathworld.wolfram.com/InverseGaussianDistribution.html" target="_top">Weisstein,
90 Eric W. "Inverse Gaussian Distribution." From MathWorld--A Wolfram
94 If you want a <code class="computeroutput"><span class="keyword">double</span></code> precision
95 inverse_gaussian distribution you can use
97 <pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">inverse_gaussian_distribution</span><span class="special"><></span></pre>
99 or, more conveniently, you can write
101 <pre class="programlisting"><span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">inverse_gaussian</span><span class="special">;</span>
102 <span class="identifier">inverse_gaussian</span> <span class="identifier">my_ig</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">);</span>
105 For mean parameters μ and scale (also called precision) parameter λ, and random
106 variate x, the inverse_gaussian distribution is defined by the probability
107 density function (PDF):
109 <div class="blockquote"><blockquote class="blockquote"><p>
110 <span class="serif_italic">f(x;μ, λ) = √(λ/2πx<sup>3</sup>) e<sup>-λ(x-μ)²/2μ²x</sup> </span>
111 </p></blockquote></div>
113 and Cumulative Density Function (CDF):
115 <div class="blockquote"><blockquote class="blockquote"><p>
116 <span class="serif_italic">F(x;μ, λ) = Φ{√(λ<span class="emphasis"><em>x) (x</em></span>μ-1)}
117 + e<sup>2μ/λ</sup> Φ{-√(λ/μ) (1+x/μ)} </span>
118 </p></blockquote></div>
120 where Φ is the standard normal distribution CDF.
123 The following graphs illustrate how the PDF and CDF of the inverse_gaussian
124 distribution varies for a few values of parameters μ and λ:
126 <div class="blockquote"><blockquote class="blockquote"><p>
127 <span class="inlinemediaobject"><img src="../../../../graphs/inverse_gaussian_pdf.svg" align="middle"></span>
129 </p></blockquote></div>
130 <div class="blockquote"><blockquote class="blockquote"><p>
131 <span class="inlinemediaobject"><img src="../../../../graphs/inverse_gaussian_cdf.svg" align="middle"></span>
133 </p></blockquote></div>
135 Tweedie also provided 3 other parameterisations where (μ and λ) are replaced
136 by their ratio φ = λ/μ and by 1/μ: these forms may be more suitable for Bayesian
137 applications. These can be found on Seshadri, page 2 and are also discussed
138 by Chhikara and Folks on page 105. Another related parameterisation, the
139 __wald_distrib (where mean μ is unity) is also provided.
142 <a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h0"></a>
143 <span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.member_functions"></a></span><a class="link" href="inverse_gaussian_dist.html#math_toolkit.dist_ref.dists.inverse_gaussian_dist.member_functions">Member
146 <pre class="programlisting"><span class="identifier">inverse_gaussian_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">df</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">scale</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span> <span class="comment">// optionally scaled.</span>
149 Constructs an inverse_gaussian distribution with μ mean, and scale λ, with
150 both default values 1.
153 Requires that both the mean μ parameter and scale λ are greater than zero,
154 otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
156 <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
159 Returns the mean μ parameter of this distribution.
161 <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
164 Returns the scale λ parameter of this distribution.
167 <a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h1"></a>
168 <span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.non_member_accessors"></a></span><a class="link" href="inverse_gaussian_dist.html#math_toolkit.dist_ref.dists.inverse_gaussian_dist.non_member_accessors">Non-member
172 All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
173 functions</a> that are generic to all distributions are supported:
174 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
175 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
176 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard Function</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard Function</a>,
177 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.mean">mean</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.median">median</a>,
178 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.mode">mode</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.variance">variance</a>,
179 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
180 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.skewness">skewness</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis">kurtosis</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess</a>,
181 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.range">range</a> and <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.support">support</a>.
184 The domain of the random variate is [0,+∞).
186 <div class="note"><table border="0" summary="Note">
188 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
189 <th align="left">Note</th>
191 <tr><td align="left" valign="top"><p>
192 Unlike some definitions, this implementation supports a random variate
193 equal to zero as a special case, returning zero for both pdf and cdf.
197 <a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h2"></a>
198 <span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.accuracy"></a></span><a class="link" href="inverse_gaussian_dist.html#math_toolkit.dist_ref.dists.inverse_gaussian_dist.accuracy">Accuracy</a>
201 The inverse_gaussian distribution is implemented in terms of the exponential
202 function and standard normal distribution <span class="emphasis"><em>N</em></span>0,1 Φ : refer
203 to the accuracy data for those functions for more information. But in general,
204 gamma (and thus inverse gamma) results are often accurate to a few epsilon,
205 >14 decimal digits accuracy for 64-bit double.
208 <a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h3"></a>
209 <span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.implementation"></a></span><a class="link" href="inverse_gaussian_dist.html#math_toolkit.dist_ref.dists.inverse_gaussian_dist.implementation">Implementation</a>
212 In the following table μ is the mean parameter and λ is the scale parameter
213 of the inverse_gaussian distribution, <span class="emphasis"><em>x</em></span> is the random
214 variate, <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q = 1-p</em></span>
215 its complement. Parameters μ for shape and λ for scale are used for the inverse
218 <div class="informaltable"><table class="table">
244 √(λ/ 2πx<sup>3</sup>) e<sup>-λ(x - μ)²/ 2μ²x</sup>
256 Φ{√(λ<span class="emphasis"><em>x) (x</em></span>μ-1)} + e<sup>2μ/λ</sup> Φ{-√(λ/μ) (1+x/μ)}
268 using complement of Φ above.
280 No closed form known. Estimated using a guess refined by Newton-Raphson
288 quantile from the complement
293 No closed form known. Estimated using a guess refined by Newton-Raphson
306 μ {√(1+9μ²/4λ²)² - 3μ/2λ}
318 No closed form analytic equation is known, but is evaluated as
355 3 √ (μ/λ)
386 <a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h4"></a>
387 <span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.references"></a></span><a class="link" href="inverse_gaussian_dist.html#math_toolkit.dist_ref.dists.inverse_gaussian_dist.references">References</a>
389 <div class="orderedlist"><ol class="orderedlist" type="1">
390 <li class="listitem">
391 Wald, A. (1947). Sequential analysis. Wiley, NY.
393 <li class="listitem">
394 The Inverse Gaussian distribution : theory, methodology, and applications,
395 Raj S. Chhikara, J. Leroy Folks. ISBN 0824779975 (1989).
397 <li class="listitem">
398 The Inverse Gaussian distribution : statistical theory and applications,
399 Seshadri, V , ISBN - 0387986189 (pbk) (Dewey 519.2) (1998).
401 <li class="listitem">
402 <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.wald.html" target="_top">Numpy
403 and Scipy Documentation</a>.
405 <li class="listitem">
406 <a href="http://bm2.genes.nig.ac.jp/RGM2/R_current/library/statmod/man/invgauss.html" target="_top">R
407 statmod invgauss functions</a>.
409 <li class="listitem">
410 <a href="http://cran.r-project.org/web/packages/SuppDists/index.html" target="_top">R
411 SuppDists invGauss functions</a>. (Note that these R implementations
412 names differ in case).
414 <li class="listitem">
415 <a href="http://www.statsci.org/s/invgauss.html" target="_top">StatSci.org invgauss
418 <li class="listitem">
419 <a href="http://www.statsci.org/s/invgauss.statSci.org" target="_top">invgauss
422 <li class="listitem">
423 <a href="http://www.biostat.wustl.edu/archives/html/s-news/2001-12/msg00144.html" target="_top">pwald,
426 <li class="listitem">
427 <a href="http://www.brighton-webs.co.uk/distributions/wald.asp" target="_top">Brighton
432 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
433 <td align="left"></td>
434 <td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar
435 Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
436 Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
437 Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
438 Daryle Walker and Xiaogang Zhang<p>
439 Distributed under the Boost Software License, Version 1.0. (See accompanying
440 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
445 <div class="spirit-nav">
446 <a accesskey="p" href="inverse_gamma_dist.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="laplace_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>