Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / math / doc / html / math_toolkit / dist_ref / dists / inverse_gaussian_dist.html
1 <html>
2 <head>
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.78.1">
7 <link rel="home" href="../../../index.html" title="Math Toolkit 2.1.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">
11 </head>
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>
20 </tr></table>
21 <hr>
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>
24 </div>
25 <div class="section">
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">&lt;</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">&gt;</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>
32
33 <span class="keyword">template</span> <span class="special">&lt;</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&#160;14.&#160;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&lt;&gt;</a> <span class="special">&gt;</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>
40
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>
42
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">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">inverse_gaussian</span><span class="special">;</span>
48
49 <span class="special">}}</span> <span class="comment">// namespace boost // namespace math</span>
50 </pre>
51 <p>
52           The Inverse Gaussian distribution distribution is a continuous probability
53           distribution.
54         </p>
55 <p>
56           The distribution is also called 'normal-inverse Gaussian distribution',
57           and 'normal Inverse' distribution.
58         </p>
59 <p>
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
67           distributions</a>.
68         </p>
69 <p>
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).
71         </p>
72 <p>
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.
79         </p>
80 <p>
81           Examples are returns from financial assets and turbulent wind speeds.
82         </p>
83 <p>
84           The normal-inverse Gaussian distributions form a subclass of the generalised
85           hyperbolic distributions.
86         </p>
87 <p>
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
91           Web Resource.</a>
92         </p>
93 <p>
94           If you want a <code class="computeroutput"><span class="keyword">double</span></code> precision
95           inverse_gaussian distribution you can use
96         </p>
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">&lt;&gt;</span></pre>
98 <p>
99           or, more conveniently, you can write
100         </p>
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>
103 </pre>
104 <p>
105           For mean parameters &#956; and scale (also called precision) parameter &#955;, and random
106           variate x, the inverse_gaussian distribution is defined by the probability
107           density function (PDF):
108         </p>
109 <p>
110           &#8192;&#8192; f(x;&#956;, &#955;) = &#8730;(&#955;/2&#960;x<sup>3</sup>) e<sup>-&#955;(x-&#956;)&#178;/2&#956;&#178;x</sup>
111         </p>
112 <p>
113           and Cumulative Density Function (CDF):
114         </p>
115 <p>
116           &#8192;&#8192;  F(x;&#956;, &#955;) = &#934;{&#8730;(&#955;<span class="emphasis"><em>x) (x</em></span>&#956;-1)} + e<sup>2&#956;/&#955;</sup> &#934;{-&#8730;(&#955;/&#956;) (1+x/&#956;)}
117         </p>
118 <p>
119           where &#934; is the standard normal distribution CDF.
120         </p>
121 <p>
122           The following graphs illustrate how the PDF and CDF of the inverse_gaussian
123           distribution varies for a few values of parameters &#956; and &#955;:
124         </p>
125 <p>
126           <span class="inlinemediaobject"><img src="../../../../graphs/inverse_gaussian_pdf.png" align="middle"></span>
127         </p>
128 <p>
129           <span class="inlinemediaobject"><img src="../../../../graphs/inverse_gaussian_cdf.png" align="middle"></span>
130         </p>
131 <p>
132           Tweedie also provided 3 other parameterisations where (&#956; and &#955;) are replaced
133           by their ratio &#966; = &#955;/&#956; and by 1/&#956;: these forms may be more suitable for Bayesian
134           applications. These can be found on Seshadri, page 2 and are also discussed
135           by Chhikara and Folks on page 105. Another related parameterisation, the
136           __wald_distrib (where mean &#956; is unity) is also provided.
137         </p>
138 <h5>
139 <a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h0"></a>
140           <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
141           Functions</a>
142         </h5>
143 <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>
144 </pre>
145 <p>
146           Constructs an inverse_gaussian distribution with &#956; mean, and scale &#955;, with
147           both default values 1.
148         </p>
149 <p>
150           Requires that both the mean &#956; parameter and scale &#955; are greater than zero,
151           otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
152         </p>
153 <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>
154 </pre>
155 <p>
156           Returns the mean &#956; parameter of this distribution.
157         </p>
158 <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>
159 </pre>
160 <p>
161           Returns the scale &#955; parameter of this distribution.
162         </p>
163 <h5>
164 <a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h1"></a>
165           <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
166           Accessors</a>
167         </h5>
168 <p>
169           All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
170           functions</a> that are generic to all distributions are supported:
171           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
172           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
173           <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>,
174           <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>,
175           <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>,
176           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
177           <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>,
178           <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>.
179         </p>
180 <p>
181           The domain of the random variate is [0,+&#8734;).
182         </p>
183 <div class="note"><table border="0" summary="Note">
184 <tr>
185 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
186 <th align="left">Note</th>
187 </tr>
188 <tr><td align="left" valign="top"><p>
189             Unlike some definitions, this implementation supports a random variate
190             equal to zero as a special case, returning zero for both pdf and cdf.
191           </p></td></tr>
192 </table></div>
193 <h5>
194 <a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h2"></a>
195           <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>
196         </h5>
197 <p>
198           The inverse_gaussian distribution is implemented in terms of the exponential
199           function and standard normal distribution <span class="emphasis"><em>N</em></span>0,1 &#934; : refer
200           to the accuracy data for those functions for more information. But in general,
201           gamma (and thus inverse gamma) results are often accurate to a few epsilon,
202           &gt;14 decimal digits accuracy for 64-bit double.
203         </p>
204 <h5>
205 <a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h3"></a>
206           <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>
207         </h5>
208 <p>
209           In the following table &#956; is the mean parameter and &#955; is the scale parameter
210           of the inverse_gaussian distribution, <span class="emphasis"><em>x</em></span> is the random
211           variate, <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q = 1-p</em></span>
212           its complement. Parameters &#956; for shape and &#955; for scale are used for the inverse
213           gaussian function.
214         </p>
215 <div class="informaltable"><table class="table">
216 <colgroup>
217 <col>
218 <col>
219 </colgroup>
220 <thead><tr>
221 <th>
222                   <p>
223                     Function
224                   </p>
225                 </th>
226 <th>
227                   <p>
228                     Implementation Notes
229                   </p>
230                 </th>
231 </tr></thead>
232 <tbody>
233 <tr>
234 <td>
235                   <p>
236                     pdf
237                   </p>
238                 </td>
239 <td>
240                   <p>
241                     &#8730;(&#955;/ 2&#960;x<sup>3</sup>) e<sup>-&#955;(x - &#956;)&#178;/ 2&#956;&#178;x</sup>
242                   </p>
243                 </td>
244 </tr>
245 <tr>
246 <td>
247                   <p>
248                     cdf
249                   </p>
250                 </td>
251 <td>
252                   <p>
253                     &#934;{&#8730;(&#955;<span class="emphasis"><em>x) (x</em></span>&#956;-1)} + e<sup>2&#956;/&#955;</sup> &#934;{-&#8730;(&#955;/&#956;) (1+x/&#956;)}
254                   </p>
255                 </td>
256 </tr>
257 <tr>
258 <td>
259                   <p>
260                     cdf complement
261                   </p>
262                 </td>
263 <td>
264                   <p>
265                     using complement of &#934; above.
266                   </p>
267                 </td>
268 </tr>
269 <tr>
270 <td>
271                   <p>
272                     quantile
273                   </p>
274                 </td>
275 <td>
276                   <p>
277                     No closed form known. Estimated using a guess refined by Newton-Raphson
278                     iteration.
279                   </p>
280                 </td>
281 </tr>
282 <tr>
283 <td>
284                   <p>
285                     quantile from the complement
286                   </p>
287                 </td>
288 <td>
289                   <p>
290                     No closed form known. Estimated using a guess refined by Newton-Raphson
291                     iteration.
292                   </p>
293                 </td>
294 </tr>
295 <tr>
296 <td>
297                   <p>
298                     mode
299                   </p>
300                 </td>
301 <td>
302                   <p>
303                     &#956; {&#8730;(1+9&#956;&#178;/4&#955;&#178;)&#178; - 3&#956;/2&#955;}
304                   </p>
305                 </td>
306 </tr>
307 <tr>
308 <td>
309                   <p>
310                     median
311                   </p>
312                 </td>
313 <td>
314                   <p>
315                     No closed form analytic equation is known, but is evaluated as
316                     quantile(0.5)
317                   </p>
318                 </td>
319 </tr>
320 <tr>
321 <td>
322                   <p>
323                     mean
324                   </p>
325                 </td>
326 <td>
327                   <p>
328                     &#956;
329                   </p>
330                 </td>
331 </tr>
332 <tr>
333 <td>
334                   <p>
335                     variance
336                   </p>
337                 </td>
338 <td>
339                   <p>
340                     &#956;&#179;/&#955;
341                   </p>
342                 </td>
343 </tr>
344 <tr>
345 <td>
346                   <p>
347                     skewness
348                   </p>
349                 </td>
350 <td>
351                   <p>
352                     3 &#8730; (&#956;/&#955;)
353                   </p>
354                 </td>
355 </tr>
356 <tr>
357 <td>
358                   <p>
359                     kurtosis_excess
360                   </p>
361                 </td>
362 <td>
363                   <p>
364                     15&#956;/&#955;
365                   </p>
366                 </td>
367 </tr>
368 <tr>
369 <td>
370                   <p>
371                     kurtosis
372                   </p>
373                 </td>
374 <td>
375                   <p>
376                     12&#956;/&#955;
377                   </p>
378                 </td>
379 </tr>
380 </tbody>
381 </table></div>
382 <h5>
383 <a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h4"></a>
384           <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>
385         </h5>
386 <div class="orderedlist"><ol class="orderedlist" type="1">
387 <li class="listitem">
388               Wald, A. (1947). Sequential analysis. Wiley, NY.
389             </li>
390 <li class="listitem">
391               The Inverse Gaussian distribution : theory, methodology, and applications,
392               Raj S. Chhikara, J. Leroy Folks. ISBN 0824779975 (1989).
393             </li>
394 <li class="listitem">
395               The Inverse Gaussian distribution : statistical theory and applications,
396               Seshadri, V , ISBN - 0387986189 (pbk) (Dewey 519.2) (1998).
397             </li>
398 <li class="listitem">
399               <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.wald.html" target="_top">Numpy
400               and Scipy Documentation</a>.
401             </li>
402 <li class="listitem">
403               <a href="http://bm2.genes.nig.ac.jp/RGM2/R_current/library/statmod/man/invgauss.html" target="_top">R
404               statmod invgauss functions</a>.
405             </li>
406 <li class="listitem">
407               <a href="http://cran.r-project.org/web/packages/SuppDists/index.html" target="_top">R
408               SuppDists invGauss functions</a>. (Note that these R implementations
409               names differ in case).
410             </li>
411 <li class="listitem">
412               <a href="http://www.statsci.org/s/invgauss.html" target="_top">StatSci.org invgauss
413               help</a>.
414             </li>
415 <li class="listitem">
416               <a href="http://www.statsci.org/s/invgauss.statSci.org" target="_top">invgauss
417               R source</a>.
418             </li>
419 <li class="listitem">
420               <a href="http://www.biostat.wustl.edu/archives/html/s-news/2001-12/msg00144.html" target="_top">pwald,
421               qwald</a>.
422             </li>
423 <li class="listitem">
424               <a href="http://www.brighton-webs.co.uk/distributions/wald.asp" target="_top">Brighton
425               Webs wald</a>.
426             </li>
427 </ol></div>
428 </div>
429 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
430 <td align="left"></td>
431 <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010, 2012-2014 Nikhar Agrawal,
432       Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
433       Holin, Bruno Lalande, John Maddock, Johan R&#229;de, Gautam Sewani, Benjamin Sobotta,
434       Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
435         Distributed under the Boost Software License, Version 1.0. (See accompanying
436         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>)
437       </p>
438 </div></td>
439 </tr></table>
440 <hr>
441 <div class="spirit-nav">
442 <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>
443 </div>
444 </body>
445 </html>