mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-07-13 14:24:08 -04:00
Squashed 'boost/' content from commit b4feb19f2
git-subtree-dir: boost git-subtree-split: b4feb19f287ee92d87a9624b5d36b7cf46aeadeb
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Distribution Algorithms</title>
|
||||
<link rel="stylesheet" href="../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dist_ref.html" title="Statistical Distributions Reference">
|
||||
<link rel="prev" href="dists/weibull_dist.html" title="Weibull Distribution">
|
||||
<link rel="next" href="../future.html" title="Extras/Future Directions">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="dists/weibull_dist.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dist_ref.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="../future.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="math_toolkit.dist_ref.dist_algorithms"></a><a class="link" href="dist_algorithms.html" title="Distribution Algorithms">Distribution Algorithms</a>
|
||||
</h3></div></div></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dist_algorithms.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dist_algorithms.finding_the_location_and_scale_f"></a></span><a class="link" href="dist_algorithms.html#math_toolkit.dist_ref.dist_algorithms.finding_the_location_and_scale_f">Finding
|
||||
the Location and Scale for Normal and similar distributions</a>
|
||||
</h5>
|
||||
<p>
|
||||
Two functions aid finding location and scale of random variable z to give
|
||||
probability p (given a scale or location). Only applies to distributions
|
||||
like normal, lognormal, extreme value, Cauchy, (and symmetrical triangular),
|
||||
that have scale and location properties.
|
||||
</p>
|
||||
<p>
|
||||
These functions are useful to predict the mean and/or standard deviation
|
||||
that will be needed to meet a specified minimum weight or maximum dose.
|
||||
</p>
|
||||
<p>
|
||||
Complement versions are also provided, both with explicit and implicit (default)
|
||||
policy.
|
||||
</p>
|
||||
<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">policies</span><span class="special">::</span><span class="identifier">policy</span><span class="special">;</span> <span class="comment">// May be needed by users defining their own policies.</span>
|
||||
<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">complement</span><span class="special">;</span> <span class="comment">// Will be needed by users who want to use complements.</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dist_algorithms.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dist_algorithms.find_location_function"></a></span><a class="link" href="dist_algorithms.html#math_toolkit.dist_ref.dist_algorithms.find_location_function">find_location
|
||||
function</a>
|
||||
</h5>
|
||||
<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">find_location</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Dist</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> <span class="comment">// explicit error handling policy</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">find_location</span><span class="special">(</span> <span class="comment">// For example, normal mean.</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">z</span><span class="special">,</span> <span class="comment">// location of random variable z to give probability, P(X > z) == p.</span>
|
||||
<span class="comment">// For example, a nominal minimum acceptable z, so that p * 100 % are > z</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// probability value desired at x, say 0.95 for 95% > z.</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">scale</span><span class="special">,</span> <span class="comment">// scale parameter, for example, normal standard deviation.</span>
|
||||
<span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&</span> <span class="identifier">pol</span><span class="special">);</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Dist</span><span class="special">></span> <span class="comment">// with default policy.</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">find_location</span><span class="special">(</span> <span class="comment">// For example, normal mean.</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">z</span><span class="special">,</span> <span class="comment">// location of random variable z to give probability, P(X > z) == p.</span>
|
||||
<span class="comment">// For example, a nominal minimum acceptable z, so that p * 100 % are > z</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// probability value desired at x, say 0.95 for 95% > z.</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">scale</span><span class="special">);</span> <span class="comment">// scale parameter, for example, normal standard deviation.</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dist_algorithms.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dist_algorithms.find_scale_function"></a></span><a class="link" href="dist_algorithms.html#math_toolkit.dist_ref.dist_algorithms.find_scale_function">find_scale
|
||||
function</a>
|
||||
</h5>
|
||||
<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">find_scale</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Dist</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">find_scale</span><span class="special">(</span> <span class="comment">// For example, normal mean.</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">z</span><span class="special">,</span> <span class="comment">// location of random variable z to give probability, P(X > z) == p.</span>
|
||||
<span class="comment">// For example, a nominal minimum acceptable weight z, so that p * 100 % are > z</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// probability value desired at x, say 0.95 for 95% > z.</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">location</span><span class="special">,</span> <span class="comment">// location parameter, for example, normal distribution mean.</span>
|
||||
<span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&</span> <span class="identifier">pol</span><span class="special">);</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Dist</span><span class="special">></span> <span class="comment">// with default policy.</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">find_scale</span><span class="special">(</span> <span class="comment">// For example, normal mean.</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">z</span><span class="special">,</span> <span class="comment">// location of random variable z to give probability, P(X > z) == p.</span>
|
||||
<span class="comment">// For example, a nominal minimum acceptable z, so that p * 100 % are > z</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// probability value desired at x, say 0.95 for 95% > z.</span>
|
||||
<span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">location</span><span class="special">)</span> <span class="comment">// location parameter, for example, normal distribution mean.</span>
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
All argument must be finite, otherwise <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
is called.
|
||||
</p>
|
||||
<p>
|
||||
Probability arguments must be [0, 1], otherwise <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
is called.
|
||||
</p>
|
||||
<p>
|
||||
If the choice of arguments would give a negative scale, <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
is called, unless the policy is to ignore, when the negative (impossible)
|
||||
value of scale is returned.
|
||||
</p>
|
||||
<p>
|
||||
<a class="link" href="../stat_tut/weg/find_eg.html" title="Find Location and Scale Examples">Find Mean and standard
|
||||
deviation examples</a> gives simple examples of use of both find_scale
|
||||
and find_location, and a longer example finding means and standard deviations
|
||||
of normally distributed weights to meet a specification.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="dists/weibull_dist.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dist_ref.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="../future.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,104 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Distributions</title>
|
||||
<link rel="stylesheet" href="../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dist_ref.html" title="Statistical Distributions Reference">
|
||||
<link rel="prev" href="nmp.html" title="Non-Member Properties">
|
||||
<link rel="next" href="dists/arcine_dist.html" title="Arcsine Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="nmp.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dist_ref.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="dists/arcine_dist.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists"></a><a class="link" href="dists.html" title="Distributions">Distributions</a>
|
||||
</h3></div></div></div>
|
||||
<div class="toc"><dl class="toc">
|
||||
<dt><span class="section"><a href="dists/arcine_dist.html">Arcsine Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/bernoulli_dist.html">Bernoulli
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/beta_dist.html">Beta Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/binomial_dist.html">Binomial
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/cauchy_dist.html">Cauchy-Lorentz
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/chi_squared_dist.html">Chi Squared
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/exp_dist.html">Exponential Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/extreme_dist.html">Extreme Value
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/f_dist.html">F Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/gamma_dist.html">Gamma (and
|
||||
Erlang) Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/geometric_dist.html">Geometric
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/hyperexponential_dist.html">Hyperexponential
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/hypergeometric_dist.html">Hypergeometric
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/inverse_chi_squared_dist.html">Inverse
|
||||
Chi Squared Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/inverse_gamma_dist.html">Inverse
|
||||
Gamma Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/inverse_gaussian_dist.html">Inverse
|
||||
Gaussian (or Inverse Normal) Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/laplace_dist.html">Laplace Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/logistic_dist.html">Logistic
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/lognormal_dist.html">Log Normal
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/negative_binomial_dist.html">Negative
|
||||
Binomial Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/nc_beta_dist.html">Noncentral
|
||||
Beta Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/nc_chi_squared_dist.html">Noncentral
|
||||
Chi-Squared Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/nc_f_dist.html">Noncentral F
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/nc_t_dist.html">Noncentral T
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/normal_dist.html">Normal (Gaussian)
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/pareto.html">Pareto Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/poisson_dist.html">Poisson Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/rayleigh.html">Rayleigh Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/skew_normal_dist.html">Skew
|
||||
Normal Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/students_t_dist.html">Students
|
||||
t Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/triangular_dist.html">Triangular
|
||||
Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/uniform_dist.html">Uniform Distribution</a></span></dt>
|
||||
<dt><span class="section"><a href="dists/weibull_dist.html">Weibull Distribution</a></span></dt>
|
||||
</dl></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="nmp.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dist_ref.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="dists/arcine_dist.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,642 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Arcsine Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="../dists.html" title="Distributions">
|
||||
<link rel="next" href="bernoulli_dist.html" title="Bernoulli Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../dists.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="bernoulli_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.arcine_dist"></a><a class="link" href="arcine_dist.html" title="Arcsine Distribution">Arcsine Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">arcsine</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">arcsine_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">arcsine_distribution</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">arcsine</span><span class="special">;</span> <span class="comment">// double precision standard arcsine distribution [0,1].</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">arcsine_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Constructor from two range parameters, x_min and x_max:</span>
|
||||
<span class="identifier">arcsine_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">x_min</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">x_max</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// Range Parameter accessors:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">x_min</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">x_max</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The class type <code class="computeroutput"><span class="identifier">arcsine_distribution</span></code>
|
||||
represents an <a href="http://en.wikipedia.org/wiki/arcsine_distribution" target="_top">arcsine</a>
|
||||
<a href="http://en.wikipedia.org/wiki/Probability_distribution" target="_top">probability
|
||||
distribution function</a>. The arcsine distribution is named because
|
||||
its CDF uses the inverse sin<sup>-1</sup> or arcsine.
|
||||
</p>
|
||||
<p>
|
||||
This is implemented as a generalized version with support from <span class="emphasis"><em>x_min</em></span>
|
||||
to <span class="emphasis"><em>x_max</em></span> providing the 'standard arcsine distribution'
|
||||
as default with <span class="emphasis"><em>x_min = 0</em></span> and <span class="emphasis"><em>x_max = 1</em></span>.
|
||||
(A few make other choices for 'standard').
|
||||
</p>
|
||||
<p>
|
||||
The arcsine distribution is generalized to include any bounded support
|
||||
<span class="emphasis"><em>a <= x <= b</em></span> by <a href="http://reference.wolfram.com/language/ref/ArcSinDistribution.html" target="_top">Wolfram</a>
|
||||
and <a href="http://en.wikipedia.org/wiki/arcsine_distribution" target="_top">Wikipedia</a>,
|
||||
but also using <span class="emphasis"><em>location</em></span> and <span class="emphasis"><em>scale</em></span>
|
||||
parameters by <a href="http://www.math.uah.edu/stat/index.html" target="_top">Virtual
|
||||
Laboratories in Probability and Statistics</a> <a href="http://www.math.uah.edu/stat/special/Arcsine.html" target="_top">Arcsine
|
||||
distribution</a>. The end-point version is simpler and more obvious,
|
||||
so we implement that. If desired, <a href="http://en.wikipedia.org/wiki/arcsine_distribution" target="_top">this</a>
|
||||
outlines how the <a class="link" href="beta_dist.html" title="Beta Distribution">Beta
|
||||
Distribution</a> can be used to add a shape factor.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability
|
||||
density function PDF</a> for the <a href="http://en.wikipedia.org/wiki/arcsine_distribution" target="_top">arcsine
|
||||
distribution</a> defined on the interval [<span class="emphasis"><em>x_min, x_max</em></span>]
|
||||
is given by:
|
||||
</p>
|
||||
<p>
|
||||
    f(x; x_min, x_max) = 1 /(π⋅√((x - x_min)⋅(x_max - x_min))
|
||||
</p>
|
||||
<p>
|
||||
For example, <a href="http://www.wolframalpha.com/" target="_top">Wolfram Alpha</a>
|
||||
arcsine distribution, from input of
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">N</span><span class="special">[</span><span class="identifier">PDF</span><span class="special">[</span><span class="identifier">arcsinedistribution</span><span class="special">[</span><span class="number">0</span><span class="special">,</span> <span class="number">1</span><span class="special">],</span> <span class="number">0.5</span><span class="special">],</span> <span class="number">50</span><span class="special">]</span>
|
||||
</pre>
|
||||
<p>
|
||||
computes the PDF value
|
||||
</p>
|
||||
<pre class="programlisting"><span class="number">0.63661977236758134307553505349005744813783858296183</span>
|
||||
</pre>
|
||||
<p>
|
||||
The Probability Density Functions (PDF) of generalized arcsine distributions
|
||||
are symmetric U-shaped curves, centered on <span class="emphasis"><em>(x_max - x_min)/2</em></span>,
|
||||
highest (infinite) near the two extrema, and quite flat over the central
|
||||
region.
|
||||
</p>
|
||||
<p>
|
||||
If random variate <span class="emphasis"><em>x</em></span> is <span class="emphasis"><em>x_min</em></span>
|
||||
or <span class="emphasis"><em>x_max</em></span>, then the PDF is infinity. If random variate
|
||||
<span class="emphasis"><em>x</em></span> is <span class="emphasis"><em>x_min</em></span> then the CDF is zero.
|
||||
If random variate <span class="emphasis"><em>x</em></span> is <span class="emphasis"><em>x_max</em></span>
|
||||
then the CDF is unity.
|
||||
</p>
|
||||
<p>
|
||||
The 'Standard' (0, 1) arcsine distribution is shown in blue and some generalized
|
||||
examples with other <span class="emphasis"><em>x</em></span> ranges.
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/arcsine_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
The Cumulative Distribution Function CDF is defined as
|
||||
</p>
|
||||
<p>
|
||||
    F(x) = 2⋅arcsin(√((x-x_min)/(x_max - x))) / π
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/arcsine_cdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.arcine_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.arcine_dist.constructor"></a></span><a class="link" href="arcine_dist.html#math_toolkit.dist_ref.dists.arcine_dist.constructor">Constructor</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="identifier">arcsine_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">x_min</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">x_max</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
constructs an arcsine distribution with range parameters <span class="emphasis"><em>x_min</em></span>
|
||||
and <span class="emphasis"><em>x_max</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Requires <span class="emphasis"><em>x_min < x_max</em></span>, otherwise <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
is called.
|
||||
</p>
|
||||
<p>
|
||||
For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">arcsine_distribution</span><span class="special"><></span> <span class="identifier">myarcsine</span><span class="special">(-</span><span class="number">2</span><span class="special">,</span> <span class="number">4</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
constructs an arcsine distribution with <span class="emphasis"><em>x_min = -2</em></span>
|
||||
and <span class="emphasis"><em>x_max = 4</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Default values of <span class="emphasis"><em>x_min = 0</em></span> and <span class="emphasis"><em>x_max =
|
||||
1</em></span> and a <code class="computeroutput"> <span class="keyword">typedef</span> <span class="identifier">arcsine_distribution</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">arcsine</span><span class="special">;</span></code>
|
||||
mean that
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">arcsine</span> <span class="identifier">as</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
constructs a 'Standard 01' arcsine distribution.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.arcine_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.arcine_dist.parameter_accessors"></a></span><a class="link" href="arcine_dist.html#math_toolkit.dist_ref.dists.arcine_dist.parameter_accessors">Parameter
|
||||
Accessors</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">x_min</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">x_max</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Return the parameter <span class="emphasis"><em>x_min</em></span> or <span class="emphasis"><em>x_max</em></span>
|
||||
from which this distribution was constructed.
|
||||
</p>
|
||||
<p>
|
||||
So, for example:
|
||||
</p>
|
||||
<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">arcsine_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">arcsine_distribution</span><span class="special"><></span> <span class="identifier">as</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">5</span><span class="special">);</span> <span class="comment">// Cconstructs a double arcsine distribution.</span>
|
||||
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">as</span><span class="special">.</span><span class="identifier">x_min</span><span class="special">()</span> <span class="special">==</span> <span class="number">2.</span><span class="special">);</span> <span class="comment">// as.x_min() returns 2.</span>
|
||||
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">as</span><span class="special">.</span><span class="identifier">x_max</span><span class="special">()</span> <span class="special">==</span> <span class="number">5.</span><span class="special">);</span> <span class="comment">// as.x_max() returns 5.</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.arcine_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.arcine_dist.non_member_accessor_functions"></a></span><a class="link" href="arcine_dist.html#math_toolkit.dist_ref.dists.arcine_dist.non_member_accessor_functions">Non-member
|
||||
Accessor Functions</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The formulae for calculating these are shown in the table below, and at
|
||||
<a href="http://mathworld.wolfram.com/arcsineDistribution.html" target="_top">Wolfram
|
||||
Mathworld</a>.
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
There are always <span class="bold"><strong>two</strong></span> values for the
|
||||
<span class="bold"><strong>mode</strong></span>, at <span class="emphasis"><em>x_min</em></span>
|
||||
and at <span class="emphasis"><em>x_max</em></span>, default 0 and 1, so instead we raise
|
||||
the exception <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
At these extrema, the PDFs are infinite, and the CDFs zero or unity.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.arcine_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.arcine_dist.applications"></a></span><a class="link" href="arcine_dist.html#math_toolkit.dist_ref.dists.arcine_dist.applications">Applications</a>
|
||||
</h5>
|
||||
<p>
|
||||
The arcsine distribution is useful to describe <a href="http://en.wikipedia.org/wiki/Random_walk" target="_top">Random
|
||||
walks</a>, (including drunken walks) <a href="http://en.wikipedia.org/wiki/Brownian_motion" target="_top">Brownian
|
||||
motion</a>, <a href="http://en.wikipedia.org/wiki/Wiener_process" target="_top">Weiner
|
||||
processes</a>, <a href="http://en.wikipedia.org/wiki/Bernoulli_trial" target="_top">Bernoulli
|
||||
trials</a>, and their appplication to solve stock market and other
|
||||
<a href="http://en.wikipedia.org/wiki/Gambler%27s_ruin" target="_top">ruinous gambling
|
||||
games</a>.
|
||||
</p>
|
||||
<p>
|
||||
The random variate <span class="emphasis"><em>x</em></span> is constrained to <span class="emphasis"><em>x_min</em></span>
|
||||
and <span class="emphasis"><em>x_max</em></span>, (for our 'standard' distribution, 0 and
|
||||
1), and is usually some fraction. For any other <span class="emphasis"><em>x_min</em></span>
|
||||
and <span class="emphasis"><em>x_max</em></span> a fraction can be obtained from <span class="emphasis"><em>x</em></span>
|
||||
using
|
||||
</p>
|
||||
<p>
|
||||
  fraction = (x - x_min) / (x_max - x_min)
|
||||
</p>
|
||||
<p>
|
||||
The simplest example is tossing heads and tails with a fair coin and modelling
|
||||
the risk of losing, or winning. Walkers (molecules, drunks...) moving left
|
||||
or right of a centre line are another common example.
|
||||
</p>
|
||||
<p>
|
||||
The random variate <span class="emphasis"><em>x</em></span> is the fraction of time spent
|
||||
on the 'winning' side. If half the time is spent on the 'winning' side
|
||||
(and so the other half on the 'losing' side) then <span class="emphasis"><em>x = 1/2</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
For large numbers of tosses, this is modelled by the (standard [0,1]) arcsine
|
||||
distribution, and the PDF can be calculated thus:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">pdf</span><span class="special">(</span><span class="identifier">as</span><span class="special">,</span> <span class="number">1.</span> <span class="special">/</span> <span class="number">2</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// 0.637</span>
|
||||
<span class="comment">// pdf has a minimum at x = 0.5</span>
|
||||
</pre>
|
||||
<p>
|
||||
From the plot of PDF, it is clear that <span class="emphasis"><em>x</em></span> = ½ is the
|
||||
<span class="bold"><strong>minimum</strong></span> of the curve, so this is the
|
||||
<span class="bold"><strong>least likely</strong></span> scenario. (This is highly
|
||||
counter-intuitive, considering that fair tosses must <span class="bold"><strong>eventually</strong></span>
|
||||
become equal. It turns out that <span class="emphasis"><em>eventually</em></span> is not
|
||||
just very long, but <span class="bold"><strong>infinite</strong></span>!).
|
||||
</p>
|
||||
<p>
|
||||
The <span class="bold"><strong>most likely</strong></span> scenarios are towards
|
||||
the extrema where <span class="emphasis"><em>x</em></span> = 0 or <span class="emphasis"><em>x</em></span>
|
||||
= 1.
|
||||
</p>
|
||||
<p>
|
||||
If fraction of time on the left is a ¼, it is only slightly more likely
|
||||
because the curve is quite flat bottomed.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">pdf</span><span class="special">(</span><span class="identifier">as</span><span class="special">,</span> <span class="number">1.</span> <span class="special">/</span> <span class="number">4</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// 0.735</span>
|
||||
</pre>
|
||||
<p>
|
||||
If we consider fair coin-tossing games being played for 100 days (hypothetically
|
||||
continuously to be 'at-limit') the person winning after day 5 will not
|
||||
change in fraction 0.144 of the cases.
|
||||
</p>
|
||||
<p>
|
||||
We can easily compute this setting <span class="emphasis"><em>x</em></span> = 5./100 = 0.05
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">cdf</span><span class="special">(</span><span class="identifier">as</span><span class="special">,</span> <span class="number">0.05</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// 0.144</span>
|
||||
</pre>
|
||||
<p>
|
||||
Similarly, we can compute from a fraction of 0.05 /2 = 0.025 (halved because
|
||||
we are considering both winners and losers) corresponding to 1 - 0.025
|
||||
or 97.5% of the gamblers, (walkers, particles...) on the <span class="bold"><strong>same
|
||||
side</strong></span> of the origin
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="number">2</span> <span class="special">*</span> <span class="identifier">cdf</span><span class="special">(</span><span class="identifier">as</span><span class="special">,</span> <span class="number">1</span> <span class="special">-</span> <span class="number">0.975</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// 0.202</span>
|
||||
</pre>
|
||||
<p>
|
||||
(use of the complement gives a bit more clarity, and avoids potential loss
|
||||
of accuracy when <span class="emphasis"><em>x</em></span> is close to unity, see <a class="link" href="../../stat_tut/overview/complements.html#why_complements">why
|
||||
complements?</a>).
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="number">2</span> <span class="special">*</span> <span class="identifier">cdf</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">as</span><span class="special">,</span> <span class="number">0.975</span><span class="special">))</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// 0.202</span>
|
||||
</pre>
|
||||
<p>
|
||||
or we can reverse the calculation by assuming a fraction of time on one
|
||||
side, say fraction 0.2,
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">as</span><span class="special">,</span> <span class="number">1</span> <span class="special">-</span> <span class="number">0.2</span> <span class="special">/</span> <span class="number">2</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// 0.976</span>
|
||||
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">as</span><span class="special">,</span> <span class="number">0.2</span> <span class="special">/</span> <span class="number">2</span><span class="special">))</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// 0.976</span>
|
||||
</pre>
|
||||
<p>
|
||||
<span class="bold"><strong>Summary</strong></span>: Every time we toss, the odds
|
||||
are equal, so on average we have the same change of winning and losing.
|
||||
</p>
|
||||
<p>
|
||||
But this is <span class="bold"><strong>not true</strong></span> for an an individual
|
||||
game where one will be <span class="bold"><strong>mostly in a bad or good patch</strong></span>.
|
||||
</p>
|
||||
<p>
|
||||
This is quite counter-intuitive to most people, but the mathematics is
|
||||
clear, and gamblers continue to provide proof.
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong>Moral</strong></span>: if you in a losing patch, leave
|
||||
the game. (Because the odds to recover to a good patch are poor).
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong>Corollary</strong></span>: Quit while you are ahead?
|
||||
</p>
|
||||
<p>
|
||||
A working example is at <a href="../../../../../example/arcsine_example.cpp" target="_top">arcsine_example.cpp</a>
|
||||
including sample output .
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.arcine_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.arcine_dist.related_distributions"></a></span><a class="link" href="arcine_dist.html#math_toolkit.dist_ref.dists.arcine_dist.related_distributions">Related
|
||||
distributions</a>
|
||||
</h5>
|
||||
<p>
|
||||
The arcsine distribution with <span class="emphasis"><em>x_min = 0</em></span> and <span class="emphasis"><em>x_max
|
||||
= 1</em></span> is special case of the <a class="link" href="beta_dist.html" title="Beta Distribution">Beta
|
||||
Distribution</a> with α = 1/2 and β = 1/2.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.arcine_dist.h5"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.arcine_dist.accuracy"></a></span><a class="link" href="arcine_dist.html#math_toolkit.dist_ref.dists.arcine_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
This distribution is implemented using sqrt, sine, cos and arc sine and
|
||||
cos trigonometric functions which are normally accurate to a few <a href="http://en.wikipedia.org/wiki/Machine_epsilon" target="_top">machine epsilon</a>.
|
||||
But all values suffer from <a href="http://en.wikipedia.org/wiki/Loss_of_significance" target="_top">loss
|
||||
of significance or cancellation error</a> for values of <span class="emphasis"><em>x</em></span>
|
||||
close to <span class="emphasis"><em>x_max</em></span>. For example, for a standard [0, 1]
|
||||
arcsine distribution <span class="emphasis"><em>as</em></span>, the pdf is symmetric about
|
||||
random variate <span class="emphasis"><em>x = 0.5</em></span> so that one would expect <code class="computeroutput"><span class="identifier">pdf</span><span class="special">(</span><span class="identifier">as</span><span class="special">,</span> <span class="number">0.01</span><span class="special">)</span> <span class="special">==</span>
|
||||
<span class="identifier">pdf</span><span class="special">(</span><span class="identifier">as</span><span class="special">,</span> <span class="number">0.99</span><span class="special">)</span></code>. But
|
||||
as <span class="emphasis"><em>x</em></span> nears unity, there is increasing <a href="http://en.wikipedia.org/wiki/Loss_of_significance" target="_top">loss
|
||||
of significance</a>. To counteract this, the complement versions of
|
||||
CDF and quantile are implemented with alternative expressions using <span class="emphasis"><em>cos<sup>-1</sup></em></span>
|
||||
instead of <span class="emphasis"><em>sin<sup>-1</sup></em></span>. Users should see <a class="link" href="../../stat_tut/overview/complements.html#why_complements">why
|
||||
complements?</a> for guidance on when to avoid loss of accuracy by using
|
||||
complements.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.arcine_dist.h6"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.arcine_dist.testing"></a></span><a class="link" href="arcine_dist.html#math_toolkit.dist_ref.dists.arcine_dist.testing">Testing</a>
|
||||
</h5>
|
||||
<p>
|
||||
The results were tested against a few accurate spot values computed by
|
||||
<a href="http://www.wolframalpha.com/" target="_top">Wolfram Alpha</a>, for example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">N</span><span class="special">[</span><span class="identifier">PDF</span><span class="special">[</span><span class="identifier">arcsinedistribution</span><span class="special">[</span><span class="number">0</span><span class="special">,</span> <span class="number">1</span><span class="special">],</span> <span class="number">0.5</span><span class="special">],</span> <span class="number">50</span><span class="special">]</span>
|
||||
<span class="number">0.63661977236758134307553505349005744813783858296183</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.arcine_dist.h7"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.arcine_dist.implementation"></a></span><a class="link" href="arcine_dist.html#math_toolkit.dist_ref.dists.arcine_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span>
|
||||
are the parameters <span class="emphasis"><em>x_min</em></span>   and <span class="emphasis"><em>x_max</em></span>,
|
||||
<span class="emphasis"><em>x</em></span> is the random variable, <span class="emphasis"><em>p</em></span> is
|
||||
the probability and its complement <span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
support
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
x ∈ [a, b], default x ∈ [0, 1]
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
f(x; a, b) = 1/(π⋅√(x - a)⋅(b - x))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
F(x) = 2/π⋅sin<sup>-1</sup>(√(x - a) / (b - a) )
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf of complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
2/(π⋅cos<sup>-1</sup>(√(x - a) / (b - a)))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
-a⋅sin<sup>2</sup>(½π⋅p) + a + b⋅sin<sup>2</sup>(½π⋅p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
-a⋅cos<sup>2</sup>(½π⋅p) + a + b⋅cos<sup>2</sup>(½π⋅q)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
½(a+b)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
median
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
½(a+b)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
x ∈ [a, b], so raises domain_error (returning NaN).
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(b - a)<sup>2</sup> / 8
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
0
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
-3/2
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis_excess + 3
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<p>
|
||||
The quantile was calculated using an expression obtained by using <a href="http://www.wolframalpha.com/" target="_top">Wolfram Alpha</a> to invert the
|
||||
formula for the CDF thus
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">solve</span> <span class="special">[</span><span class="identifier">p</span> <span class="special">-</span> <span class="number">2</span><span class="special">/</span><span class="identifier">pi</span> <span class="identifier">sin</span><span class="special">^-</span><span class="number">1</span><span class="special">(</span><span class="identifier">sqrt</span><span class="special">((</span><span class="identifier">x</span><span class="special">-</span><span class="identifier">a</span><span class="special">)/(</span><span class="identifier">b</span><span class="special">-</span><span class="identifier">a</span><span class="special">)))</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">x</span><span class="special">]</span>
|
||||
</pre>
|
||||
<p>
|
||||
which was interpreted as
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">Solve</span><span class="special">[</span><span class="identifier">p</span> <span class="special">-</span> <span class="special">(</span><span class="number">2</span> <span class="identifier">ArcSin</span><span class="special">[</span><span class="identifier">Sqrt</span><span class="special">[(-</span><span class="identifier">a</span> <span class="special">+</span> <span class="identifier">x</span><span class="special">)/(-</span><span class="identifier">a</span> <span class="special">+</span> <span class="identifier">b</span><span class="special">)]])/</span><span class="identifier">Pi</span> <span class="special">==</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">MaxExtraConditions</span> <span class="special">-></span> <span class="identifier">Automatic</span><span class="special">]</span>
|
||||
</pre>
|
||||
<p>
|
||||
and produced the resulting expression
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">x</span> <span class="special">=</span> <span class="special">-</span><span class="identifier">a</span> <span class="identifier">sin</span><span class="special">^</span><span class="number">2</span><span class="special">((</span><span class="identifier">pi</span> <span class="identifier">p</span><span class="special">)/</span><span class="number">2</span><span class="special">)+</span><span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span> <span class="identifier">sin</span><span class="special">^</span><span class="number">2</span><span class="special">((</span><span class="identifier">pi</span> <span class="identifier">p</span><span class="special">)/</span><span class="number">2</span><span class="special">)</span>
|
||||
</pre>
|
||||
<p>
|
||||
Thanks to Wolfram for providing this facility.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.arcine_dist.h8"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.arcine_dist.references"></a></span><a class="link" href="arcine_dist.html#math_toolkit.dist_ref.dists.arcine_dist.references">References</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://en.wikipedia.org/wiki/arcsine_distribution" target="_top">Wikipedia
|
||||
arcsine distribution</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://en.wikipedia.org/wiki/Beta_distribution" target="_top">Wikipedia
|
||||
Beta distribution</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://mathworld.wolfram.com/BetaDistribution.html" target="_top">Wolfram
|
||||
MathWorld</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.wolframalpha.com/" target="_top">Wolfram Alpha</a>
|
||||
</li>
|
||||
</ul></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.arcine_dist.h9"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.arcine_dist.sources"></a></span><a class="link" href="arcine_dist.html#math_toolkit.dist_ref.dists.arcine_dist.sources">Sources</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://estebanmoro.org/2009/04/the-probability-of-going-through-a-bad-patch" target="_top">The
|
||||
probability of going through a bad patch</a> Esteban Moro's Blog.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.gotohaggstrom.com/What%20do%20schmucks%20and%20the%20arc%20sine%20law%20have%20in%20common.pdf" target="_top">What
|
||||
soschumcks and the arc sine have in common</a> Peter Haggstrom.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.math.uah.edu/stat/special/Arcsine.html" target="_top">arcsine
|
||||
distribution</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://reference.wolfram.com/language/ref/ArcSinDistribution.html" target="_top">Wolfram
|
||||
reference arcsine examples</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.math.harvard.edu/library/sternberg/slides/1180908.pdf" target="_top">Shlomo
|
||||
Sternberg slides</a>.
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../dists.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="bernoulli_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,356 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Bernoulli Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="arcine_dist.html" title="Arcsine Distribution">
|
||||
<link rel="next" href="beta_dist.html" title="Beta Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="arcine_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="beta_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.bernoulli_dist"></a><a class="link" href="bernoulli_dist.html" title="Bernoulli Distribution">Bernoulli
|
||||
Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">bernoulli</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">bernoulli_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">bernoulli_distribution</span><span class="special"><></span> <span class="identifier">bernoulli</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">bernoulli_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">bernoulli_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span> <span class="comment">// Constructor.</span>
|
||||
<span class="comment">// Accessor function.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">success_fraction</span><span class="special">()</span> <span class="keyword">const</span>
|
||||
<span class="comment">// Probability of success (as a fraction).</span>
|
||||
<span class="special">};</span>
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The Bernoulli distribution is a discrete distribution of the outcome of
|
||||
a single trial with only two results, 0 (failure) or 1 (success), with
|
||||
a probability of success p.
|
||||
</p>
|
||||
<p>
|
||||
The Bernoulli distribution is the simplest building block on which other
|
||||
discrete distributions of sequences of independent Bernoulli trials can
|
||||
be based.
|
||||
</p>
|
||||
<p>
|
||||
The Bernoulli is the binomial distribution (k = 1, p) with only one trial.
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability
|
||||
density function pdf</a> f(0) = 1 - p, f(1) = p. <a href="http://en.wikipedia.org/wiki/Cumulative_Distribution_Function" target="_top">Cumulative
|
||||
distribution function</a> D(k) = if (k == 0) 1 - p else 1.
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates how the <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability
|
||||
density function pdf</a> varies with the outcome of the single trial:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/bernoulli_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
and the <a href="http://en.wikipedia.org/wiki/Cumulative_Distribution_Function" target="_top">Cumulative
|
||||
distribution function</a>
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/bernoulli_cdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.bernoulli_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.bernoulli_dist.member_functions"></a></span><a class="link" href="bernoulli_dist.html#math_toolkit.dist_ref.dists.bernoulli_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">bernoulli_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a <a href="http://en.wikipedia.org/wiki/bernoulli_distribution" target="_top">bernoulli
|
||||
distribution</a> with success_fraction <span class="emphasis"><em>p</em></span>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">success_fraction</span><span class="special">()</span> <span class="keyword">const</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>success_fraction</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.bernoulli_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.bernoulli_dist.non_member_accessors"></a></span><a class="link" href="bernoulli_dist.html#math_toolkit.dist_ref.dists.bernoulli_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is 0 and 1, and the useful supported
|
||||
range is only 0 or 1.
|
||||
</p>
|
||||
<p>
|
||||
Outside this range, functions are undefined, or may throw domain_error
|
||||
exception and make an error message available.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.bernoulli_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.bernoulli_dist.accuracy"></a></span><a class="link" href="bernoulli_dist.html#math_toolkit.dist_ref.dists.bernoulli_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The Bernoulli distribution is implemented with simple arithmetic operators
|
||||
and so should have errors within an epsilon or two.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.bernoulli_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.bernoulli_dist.implementation"></a></span><a class="link" href="bernoulli_dist.html#math_toolkit.dist_ref.dists.bernoulli_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table <span class="emphasis"><em>p</em></span> is the probability of success
|
||||
and <span class="emphasis"><em>q = 1-p</em></span>. <span class="emphasis"><em>k</em></span> is the random
|
||||
variate, either 0 or 1.
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
The Bernoulli distribution is implemented here as a <span class="emphasis"><em>strict
|
||||
discrete</em></span> distribution. If a generalised version, allowing
|
||||
k to be any real, is required then the binomial distribution with a single
|
||||
trial should be used, for example:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">binomial_distribution</span><span class="special">(</span><span class="number">1</span><span class="special">,</span>
|
||||
<span class="number">0.25</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Supported range
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
{0, 1}
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = 1 - p for k = 0, else p
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: cdf = 1 - p for k = 0, else 1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
q = 1 - p
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
if x <= (1-p) 0 else 1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
if x <= (1-p) 1 else 0
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
p
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
p * (1 - p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
if (p < 0.5) 0 else 1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(1 - 2 * p) / sqrt(p * q)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
6 * p * p - 6 * p +1/ p * q
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis -3
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.bernoulli_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.bernoulli_dist.references"></a></span><a class="link" href="bernoulli_dist.html#math_toolkit.dist_ref.dists.bernoulli_dist.references">References</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://en.wikipedia.org/wiki/Bernoulli_distribution" target="_top">Wikpedia
|
||||
Bernoulli distribution</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://mathworld.wolfram.com/BernoulliDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Bernoulli Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="arcine_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="beta_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,622 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Beta Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="bernoulli_dist.html" title="Bernoulli Distribution">
|
||||
<link rel="next" href="binomial_dist.html" title="Binomial Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="bernoulli_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="binomial_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.beta_dist"></a><a class="link" href="beta_dist.html" title="Beta Distribution">Beta Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">beta</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">beta_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// typedef beta_distribution<double> beta;</span>
|
||||
<span class="comment">// Note that this is deliberately NOT provided,</span>
|
||||
<span class="comment">// to avoid a clash with the function name beta.</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">beta_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
<span class="comment">// Constructor from two shape parameters, alpha & beta:</span>
|
||||
<span class="identifier">beta_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">b</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// Parameter accessors:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Parameter estimators of alpha or beta from mean and variance.</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_alpha</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">,</span> <span class="comment">// Expected value of mean.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">);</span> <span class="comment">// Expected value of variance.</span>
|
||||
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_beta</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">,</span> <span class="comment">// Expected value of mean.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">);</span> <span class="comment">// Expected value of variance.</span>
|
||||
|
||||
<span class="comment">// Parameter estimators from</span>
|
||||
<span class="comment">// either alpha or beta, and x and probability.</span>
|
||||
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_alpha</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">,</span> <span class="comment">// from beta.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="comment">// x.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// cdf</span>
|
||||
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_beta</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span> <span class="comment">// alpha.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="comment">// probability x.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// probability cdf.</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The class type <code class="computeroutput"><span class="identifier">beta_distribution</span></code>
|
||||
represents a <a href="http://en.wikipedia.org/wiki/Beta_distribution" target="_top">beta
|
||||
</a> <a href="http://en.wikipedia.org/wiki/Probability_distribution" target="_top">probability
|
||||
distribution function</a>.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="http://mathworld.wolfram.com/BetaDistribution.htm" target="_top">beta
|
||||
distribution </a> is used as a <a href="http://en.wikipedia.org/wiki/Prior_distribution" target="_top">prior
|
||||
distribution</a> for binomial proportions in <a href="http://mathworld.wolfram.com/BayesianAnalysis.html" target="_top">Bayesian
|
||||
analysis</a>.
|
||||
</p>
|
||||
<p>
|
||||
See also: <a href="http://documents.wolfram.com/calculationcenter/v2/Functions/ListsMatrices/Statistics/BetaDistribution.html" target="_top">beta
|
||||
distribution</a> and <a href="http://en.wikipedia.org/wiki/Bayesian_statistics" target="_top">Bayesian
|
||||
statistics</a>.
|
||||
</p>
|
||||
<p>
|
||||
How the beta distribution is used for <a href="http://home.uchicago.edu/~grynav/bayes/ABSLec5.ppt" target="_top">Bayesian
|
||||
analysis of one parameter models</a> is discussed by Jeff Grynaviski.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability
|
||||
density function PDF</a> for the <a href="http://en.wikipedia.org/wiki/Beta_distribution" target="_top">beta
|
||||
distribution</a> defined on the interval [0,1] is given by:
|
||||
</p>
|
||||
<p>
|
||||
f(x;α,β) = x<sup>α - 1</sup> (1 - x)<sup>β -1</sup> / B(α, β)
|
||||
</p>
|
||||
<p>
|
||||
where B(α, β) is the <a href="http://en.wikipedia.org/wiki/Beta_function" target="_top">beta
|
||||
function</a>, implemented in this library as <a class="link" href="../../sf_beta/beta_function.html" title="Beta">beta</a>.
|
||||
Division by the beta function ensures that the pdf is normalized to the
|
||||
range zero to unity.
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates examples of the pdf for various values
|
||||
of the shape parameters. Note the α = β = 2 (blue line) is dome-shaped, and
|
||||
might be approximated by a symmetrical triangular distribution.
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/beta_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
If α = β = 1, then it is a __space <a href="http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29" target="_top">uniform
|
||||
distribution</a>, equal to unity in the entire interval x = 0 to 1.
|
||||
If α __space and β __space are < 1, then the pdf is U-shaped. If α != β, then
|
||||
the shape is asymmetric and could be approximated by a triangle whose apex
|
||||
is away from the centre (where x = half).
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.beta_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.member_functions"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.beta_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.constructor"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.constructor">Constructor</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="identifier">beta_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a beta distribution with shape parameters <span class="emphasis"><em>alpha</em></span>
|
||||
and <span class="emphasis"><em>beta</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Requires alpha,beta > 0,otherwise <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
is called. Note that technically the beta distribution is defined for alpha,beta
|
||||
>= 0, but it's not clear whether any program can actually make use of
|
||||
that latitude or how many of the non-member functions can be usefully defined
|
||||
in that case. Therefore for now, we regard it as an error if alpha or beta
|
||||
is zero.
|
||||
</p>
|
||||
<p>
|
||||
For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">beta_distribution</span><span class="special"><></span> <span class="identifier">mybeta</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">5</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a the beta distribution with alpha=2 and beta=5 (shown in yellow
|
||||
in the graph above).
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.beta_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.parameter_accessors"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.parameter_accessors">Parameter
|
||||
Accessors</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>alpha</em></span> from which this distribution
|
||||
was constructed.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>beta</em></span> from which this distribution
|
||||
was constructed.
|
||||
</p>
|
||||
<p>
|
||||
So for example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">beta_distribution</span><span class="special"><></span> <span class="identifier">mybeta</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">5</span><span class="special">);</span>
|
||||
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">mybeta</span><span class="special">.</span><span class="identifier">alpha</span><span class="special">()</span> <span class="special">==</span> <span class="number">2.</span><span class="special">);</span> <span class="comment">// mybeta.alpha() returns 2</span>
|
||||
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">mybeta</span><span class="special">.</span><span class="identifier">beta</span><span class="special">()</span> <span class="special">==</span> <span class="number">5.</span><span class="special">);</span> <span class="comment">// mybeta.beta() returns 5</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.beta_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.parameter_estimators"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.parameter_estimators">Parameter
|
||||
Estimators</a>
|
||||
</h5>
|
||||
<p>
|
||||
Two pairs of parameter estimators are provided.
|
||||
</p>
|
||||
<p>
|
||||
One estimates either α __space or β __space from presumed-known mean and variance.
|
||||
</p>
|
||||
<p>
|
||||
The other pair estimates either α __space or β __space from the cdf and x.
|
||||
</p>
|
||||
<p>
|
||||
It is also possible to estimate α __space and β __space from 'known' mode &
|
||||
quantile. For example, calculators are provided by the <a href="http://www.ausvet.com.au/pprev/content.php?page=PPscript" target="_top">Pooled
|
||||
Prevalence Calculator</a> and <a href="http://www.epi.ucdavis.edu/diagnostictests/betabuster.html" target="_top">Beta
|
||||
Buster</a> but this is not yet implemented here.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_alpha</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">,</span> <span class="comment">// Expected value of mean.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">);</span> <span class="comment">// Expected value of variance.</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the unique value of α   that corresponds to a beta distribution with
|
||||
mean <span class="emphasis"><em>mean</em></span> and variance <span class="emphasis"><em>variance</em></span>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_beta</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">,</span> <span class="comment">// Expected value of mean.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">);</span> <span class="comment">// Expected value of variance.</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the unique value of β   that corresponds to a beta distribution with
|
||||
mean <span class="emphasis"><em>mean</em></span> and variance <span class="emphasis"><em>variance</em></span>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_alpha</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">,</span> <span class="comment">// from beta.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="comment">// x.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// probability cdf</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the value of α   that gives: <code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">beta_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>(</span><span class="identifier">alpha</span><span class="special">,</span> <span class="identifier">beta</span><span class="special">),</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">probability</span></code>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_beta</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span> <span class="comment">// alpha.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="comment">// probability x.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// probability cdf.</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the value of β   that gives: <code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">beta_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>(</span><span class="identifier">alpha</span><span class="special">,</span> <span class="identifier">beta</span><span class="special">),</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">probability</span></code>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.beta_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.non_member_accessor_functions"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.non_member_accessor_functions">Non-member
|
||||
Accessor Functions</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The formulae for calculating these are shown in the table below, and at
|
||||
<a href="http://mathworld.wolfram.com/BetaDistribution.html" target="_top">Wolfram
|
||||
Mathworld</a>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.beta_dist.h5"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.applications"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.applications">Applications</a>
|
||||
</h5>
|
||||
<p>
|
||||
The beta distribution can be used to model events constrained to take place
|
||||
within an interval defined by a minimum and maximum value: so it is used
|
||||
in project management systems.
|
||||
</p>
|
||||
<p>
|
||||
It is also widely used in <a href="http://en.wikipedia.org/wiki/Bayesian_inference" target="_top">Bayesian
|
||||
statistical inference</a>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.beta_dist.h6"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.related_distributions"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.related_distributions">Related
|
||||
distributions</a>
|
||||
</h5>
|
||||
<p>
|
||||
The beta distribution with both α __space and β = 1 follows a <a href="http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29" target="_top">uniform
|
||||
distribution</a>.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Triangular_distribution" target="_top">triangular</a>
|
||||
is used when less precise information is available.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Binomial_distribution" target="_top">binomial
|
||||
distribution</a> is closely related when α __space and β __space are integers.
|
||||
</p>
|
||||
<p>
|
||||
With integer values of α __space and β __space the distribution B(i, j) is
|
||||
that of the j-th highest of a sample of i + j + 1 independent random variables
|
||||
uniformly distributed between 0 and 1. The cumulative probability from
|
||||
0 to x is thus the probability that the j-th highest value is less than
|
||||
x. Or it is the probability that at least i of the random variables are
|
||||
less than x, a probability given by summing over the <a class="link" href="binomial_dist.html" title="Binomial Distribution">Binomial
|
||||
Distribution</a> with its p parameter set to x.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.beta_dist.h7"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.accuracy"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
This distribution is implemented using the <a class="link" href="../../sf_beta/beta_function.html" title="Beta">beta
|
||||
functions</a> <a class="link" href="../../sf_beta/beta_function.html" title="Beta">beta</a>
|
||||
and <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">incomplete beta
|
||||
functions</a> <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>
|
||||
and <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>;
|
||||
please refer to these functions for information on accuracy.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.beta_dist.h8"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.implementation"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span>
|
||||
are the parameters α   and β, <span class="emphasis"><em>x</em></span> is the random variable,
|
||||
<span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
f(x;α,β) = x<sup>α - 1</sup> (1 - x)<sup>β -1</sup> / B(α, β)
|
||||
</p>
|
||||
<p>
|
||||
Implemented using <a class="link" href="../../sf_beta/beta_derivative.html" title="Derivative of the Incomplete Beta Function">ibeta_derivative</a>(a,
|
||||
b, x).
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the incomplete beta function <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>(a,
|
||||
b, x)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>(a,
|
||||
b, x)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the inverse incomplete beta function <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_inv</a>(a,
|
||||
b, p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibetac_inv</a>(a,
|
||||
b, q)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">a</span><span class="special">/(</span><span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">a</span> <span class="special">*</span>
|
||||
<span class="identifier">b</span> <span class="special">/</span>
|
||||
<span class="special">(</span><span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span><span class="special">)^</span><span class="number">2</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">+</span>
|
||||
<span class="identifier">b</span> <span class="special">+</span>
|
||||
<span class="number">1</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">(</span><span class="identifier">a</span><span class="special">-</span><span class="number">1</span><span class="special">)</span> <span class="special">/</span>
|
||||
<span class="special">(</span><span class="identifier">a</span>
|
||||
<span class="special">+</span> <span class="identifier">b</span>
|
||||
<span class="special">-</span> <span class="number">2</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="number">2</span> <span class="special">(</span><span class="identifier">b</span><span class="special">-</span><span class="identifier">a</span><span class="special">)</span>
|
||||
<span class="identifier">sqrt</span><span class="special">(</span><span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span><span class="special">+</span><span class="number">1</span><span class="special">)/(</span><span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span><span class="special">+</span><span class="number">2</span><span class="special">)</span> <span class="special">*</span> <span class="identifier">sqrt</span><span class="special">(</span><span class="identifier">a</span>
|
||||
<span class="special">*</span> <span class="identifier">b</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/beta_dist_kurtosis.svg"></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">kurtosis</span> <span class="special">+</span>
|
||||
<span class="number">3</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
parameter estimation
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
alpha
|
||||
</p>
|
||||
<p>
|
||||
from mean and variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">mean</span> <span class="special">*</span>
|
||||
<span class="special">((</span> <span class="special">(</span><span class="identifier">mean</span> <span class="special">*</span>
|
||||
<span class="special">(</span><span class="number">1</span>
|
||||
<span class="special">-</span> <span class="identifier">mean</span><span class="special">))</span> <span class="special">/</span>
|
||||
<span class="identifier">variance</span><span class="special">)-</span>
|
||||
<span class="number">1</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
beta
|
||||
</p>
|
||||
<p>
|
||||
from mean and variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">(</span><span class="number">1</span>
|
||||
<span class="special">-</span> <span class="identifier">mean</span><span class="special">)</span> <span class="special">*</span>
|
||||
<span class="special">(((</span><span class="identifier">mean</span>
|
||||
<span class="special">*</span> <span class="special">(</span><span class="number">1</span> <span class="special">-</span> <span class="identifier">mean</span><span class="special">))</span>
|
||||
<span class="special">/</span><span class="identifier">variance</span><span class="special">)-</span><span class="number">1</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
The member functions <code class="computeroutput"><span class="identifier">find_alpha</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">find_beta</span></code>
|
||||
</p>
|
||||
<p>
|
||||
from cdf and probability x
|
||||
</p>
|
||||
<p>
|
||||
and <span class="bold"><strong>either</strong></span> <code class="computeroutput"><span class="identifier">alpha</span></code>
|
||||
or <code class="computeroutput"><span class="identifier">beta</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Implemented in terms of the inverse incomplete beta functions
|
||||
</p>
|
||||
<p>
|
||||
<a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_inva</a>,
|
||||
and <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_invb</a>
|
||||
respectively.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">find_alpha</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">ibeta_inva</span><span class="special">(</span><span class="identifier">beta</span><span class="special">,</span>
|
||||
<span class="identifier">x</span><span class="special">,</span>
|
||||
<span class="identifier">probability</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">find_beta</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">ibeta_invb</span><span class="special">(</span><span class="identifier">alpha</span><span class="special">,</span>
|
||||
<span class="identifier">x</span><span class="special">,</span>
|
||||
<span class="identifier">probability</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.beta_dist.h9"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.references"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.references">References</a>
|
||||
</h5>
|
||||
<p>
|
||||
<a href="http://en.wikipedia.org/wiki/Beta_distribution" target="_top">Wikipedia Beta
|
||||
distribution</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda366h.htm" target="_top">NIST
|
||||
Exploratory Data Analysis</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://mathworld.wolfram.com/BetaDistribution.html" target="_top">Wolfram
|
||||
MathWorld</a>
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="bernoulli_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="binomial_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,908 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Binomial Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="beta_dist.html" title="Beta Distribution">
|
||||
<link rel="next" href="cauchy_dist.html" title="Cauchy-Lorentz Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="beta_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="cauchy_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist"></a><a class="link" href="binomial_dist.html" title="Binomial Distribution">Binomial
|
||||
Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">binomial</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">binomial_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">binomial_distribution</span><span class="special"><></span> <span class="identifier">binomial</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">binomial_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">static</span> <span class="keyword">const</span> <span class="emphasis"><em>unspecified-type</em></span> <span class="identifier">clopper_pearson_exact_interval</span><span class="special">;</span>
|
||||
<span class="keyword">static</span> <span class="keyword">const</span> <span class="emphasis"><em>unspecified-type</em></span> <span class="identifier">jeffreys_prior_interval</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// construct:</span>
|
||||
<span class="identifier">binomial_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// parameter access::</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">success_fraction</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">trials</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Bounds on success fraction:</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_lower_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">trials</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">,</span>
|
||||
<span class="emphasis"><em>unspecified-type</em></span> <span class="identifier">method</span> <span class="special">=</span> <span class="identifier">clopper_pearson_exact_interval</span><span class="special">);</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_upper_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">trials</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">,</span>
|
||||
<span class="emphasis"><em>unspecified-type</em></span> <span class="identifier">method</span> <span class="special">=</span> <span class="identifier">clopper_pearson_exact_interval</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// estimate min/max number of trials:</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_minimum_number_of_trials</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">k</span><span class="special">,</span> <span class="comment">// number of events</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// success fraction</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">);</span> <span class="comment">// risk level</span>
|
||||
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_maximum_number_of_trials</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">k</span><span class="special">,</span> <span class="comment">// number of events</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// success fraction</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">);</span> <span class="comment">// risk level</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The class type <code class="computeroutput"><span class="identifier">binomial_distribution</span></code>
|
||||
represents a <a href="http://mathworld.wolfram.com/BinomialDistribution.html" target="_top">binomial
|
||||
distribution</a>: it is used when there are exactly two mutually exclusive
|
||||
outcomes of a trial. These outcomes are labelled "success" and
|
||||
"failure". The <a class="link" href="binomial_dist.html" title="Binomial Distribution">Binomial
|
||||
Distribution</a> is used to obtain the probability of observing k successes
|
||||
in N trials, with the probability of success on a single trial denoted
|
||||
by p. The binomial distribution assumes that p is fixed for all trials.
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
The random variable for the binomial distribution is the number of successes,
|
||||
(the number of trials is a fixed property of the distribution) whereas
|
||||
for the negative binomial, the random variable is the number of trials,
|
||||
for a fixed number of successes.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
The PDF for the binomial distribution is given by:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/binomial_ref2.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
The following two graphs illustrate how the PDF changes depending upon
|
||||
the distributions parameters, first we'll keep the success fraction <span class="emphasis"><em>p</em></span>
|
||||
fixed at 0.5, and vary the sample size:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/binomial_pdf_1.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
Alternatively, we can keep the sample size fixed at N=20 and vary the success
|
||||
fraction <span class="emphasis"><em>p</em></span>:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/binomial_pdf_2.svg" align="middle"></span>
|
||||
</p>
|
||||
<div class="caution"><table border="0" summary="Caution">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../../doc/src/images/caution.png"></td>
|
||||
<th align="left">Caution</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
The Binomial distribution is a discrete distribution: internally, functions
|
||||
like the <code class="computeroutput"><span class="identifier">cdf</span></code> and <code class="computeroutput"><span class="identifier">pdf</span></code> are treated "as if" they
|
||||
are continuous functions, but in reality the results returned from these
|
||||
functions only have meaning if an integer value is provided for the random
|
||||
variate argument.
|
||||
</p>
|
||||
<p>
|
||||
The quantile function will by default return an integer result that has
|
||||
been <span class="emphasis"><em>rounded outwards</em></span>. That is to say lower quantiles
|
||||
(where the probability is less than 0.5) are rounded downward, and upper
|
||||
quantiles (where the probability is greater than 0.5) are rounded upwards.
|
||||
This behaviour ensures that if an X% quantile is requested, then <span class="emphasis"><em>at
|
||||
least</em></span> the requested coverage will be present in the central
|
||||
region, and <span class="emphasis"><em>no more than</em></span> the requested coverage
|
||||
will be present in the tails.
|
||||
</p>
|
||||
<p>
|
||||
This behaviour can be changed so that the quantile functions are rounded
|
||||
differently, or even return a real-valued result using <a class="link" href="../../pol_overview.html" title="Policy Overview">Policies</a>.
|
||||
It is strongly recommended that you read the tutorial <a class="link" href="../../pol_tutorial/understand_dis_quant.html" title="Understanding Quantiles of Discrete Distributions">Understanding
|
||||
Quantiles of Discrete Distributions</a> before using the quantile
|
||||
function on the Binomial distribution. The <a class="link" href="../../pol_ref/discrete_quant_ref.html" title="Discrete Quantile Policies">reference
|
||||
docs</a> describe how to change the rounding policy for these distributions.
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.binomial_dist.member_functions"></a></span><a class="link" href="binomial_dist.html#math_toolkit.dist_ref.dists.binomial_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.binomial_dist.construct"></a></span><a class="link" href="binomial_dist.html#math_toolkit.dist_ref.dists.binomial_dist.construct">Construct</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="identifier">binomial_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructor: <span class="emphasis"><em>n</em></span> is the total number of trials, <span class="emphasis"><em>p</em></span>
|
||||
is the probability of success of a single trial.
|
||||
</p>
|
||||
<p>
|
||||
Requires <code class="computeroutput"><span class="number">0</span> <span class="special"><=</span>
|
||||
<span class="identifier">p</span> <span class="special"><=</span>
|
||||
<span class="number">1</span></code>, and <code class="computeroutput"><span class="identifier">n</span>
|
||||
<span class="special">>=</span> <span class="number">0</span></code>,
|
||||
otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.binomial_dist.accessors"></a></span><a class="link" href="binomial_dist.html#math_toolkit.dist_ref.dists.binomial_dist.accessors">Accessors</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">success_fraction</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>p</em></span> from which this distribution
|
||||
was constructed.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">trials</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>n</em></span> from which this distribution
|
||||
was constructed.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.binomial_dist.lower_bound_on_the_success_fract"></a></span><a class="link" href="binomial_dist.html#math_toolkit.dist_ref.dists.binomial_dist.lower_bound_on_the_success_fract">Lower
|
||||
Bound on the Success Fraction</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_lower_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">trials</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span>
|
||||
<span class="emphasis"><em>unspecified-type</em></span> <span class="identifier">method</span> <span class="special">=</span> <span class="identifier">clopper_pearson_exact_interval</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns a lower bound on the success fraction:
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">trials</span></dt>
|
||||
<dd><p>
|
||||
The total number of trials conducted.
|
||||
</p></dd>
|
||||
<dt><span class="term">successes</span></dt>
|
||||
<dd><p>
|
||||
The number of successes that occurred.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The largest acceptable probability that the true value of the success
|
||||
fraction is <span class="bold"><strong>less than</strong></span> the value
|
||||
returned.
|
||||
</p></dd>
|
||||
<dt><span class="term">method</span></dt>
|
||||
<dd><p>
|
||||
An optional parameter that specifies the method to be used to compute
|
||||
the interval (See below).
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
For example, if you observe <span class="emphasis"><em>k</em></span> successes from <span class="emphasis"><em>n</em></span>
|
||||
trials the best estimate for the success fraction is simply <span class="emphasis"><em>k/n</em></span>,
|
||||
but if you want to be 95% sure that the true value is <span class="bold"><strong>greater
|
||||
than</strong></span> some value, <span class="emphasis"><em>p<sub>min</sub></em></span>, then:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">p</span><sub>min</sub> <span class="special">=</span> <span class="identifier">binomial_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">find_lower_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">n</span><span class="special">,</span> <span class="identifier">k</span><span class="special">,</span> <span class="number">0.05</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
<a class="link" href="../../stat_tut/weg/binom_eg/binom_conf.html" title="Calculating Confidence Limits on the Frequency of Occurrence for a Binomial Distribution">See worked
|
||||
example.</a>
|
||||
</p>
|
||||
<p>
|
||||
There are currently two possible values available for the <span class="emphasis"><em>method</em></span>
|
||||
optional parameter: <span class="emphasis"><em>clopper_pearson_exact_interval</em></span>
|
||||
or <span class="emphasis"><em>jeffreys_prior_interval</em></span>. These constants are both
|
||||
members of class template <code class="computeroutput"><span class="identifier">binomial_distribution</span></code>,
|
||||
so usage is for example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">p</span> <span class="special">=</span> <span class="identifier">binomial_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">find_lower_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">n</span><span class="special">,</span> <span class="identifier">k</span><span class="special">,</span> <span class="number">0.05</span><span class="special">,</span> <span class="identifier">binomial_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">jeffreys_prior_interval</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
The default method if this parameter is not specified is the Clopper Pearson
|
||||
"exact" interval. This produces an interval that guarantees at
|
||||
least <code class="computeroutput"><span class="number">100</span><span class="special">(</span><span class="number">1</span><span class="special">-</span><span class="identifier">alpha</span><span class="special">)%</span></code> coverage, but which is known to be overly
|
||||
conservative, sometimes producing intervals with much greater than the
|
||||
requested coverage.
|
||||
</p>
|
||||
<p>
|
||||
The alternative calculation method produces a non-informative Jeffreys
|
||||
Prior interval. It produces <code class="computeroutput"><span class="number">100</span><span class="special">(</span><span class="number">1</span><span class="special">-</span><span class="identifier">alpha</span><span class="special">)%</span></code>
|
||||
coverage only <span class="emphasis"><em>in the average case</em></span>, though is typically
|
||||
very close to the requested coverage level. It is one of the main methods
|
||||
of calculation recommended in the review by Brown, Cai and DasGupta.
|
||||
</p>
|
||||
<p>
|
||||
Please note that the "textbook" calculation method using a normal
|
||||
approximation (the Wald interval) is deliberately not provided: it is known
|
||||
to produce consistently poor results, even when the sample size is surprisingly
|
||||
large. Refer to Brown, Cai and DasGupta for a full explanation. Many other
|
||||
methods of calculation are available, and may be more appropriate for specific
|
||||
situations. Unfortunately there appears to be no consensus amongst statisticians
|
||||
as to which is "best": refer to the discussion at the end of
|
||||
Brown, Cai and DasGupta for examples.
|
||||
</p>
|
||||
<p>
|
||||
The two methods provided here were chosen principally because they can
|
||||
be used for both one and two sided intervals. See also:
|
||||
</p>
|
||||
<p>
|
||||
Lawrence D. Brown, T. Tony Cai and Anirban DasGupta (2001), Interval Estimation
|
||||
for a Binomial Proportion, Statistical Science, Vol. 16, No. 2, 101-133.
|
||||
</p>
|
||||
<p>
|
||||
T. Tony Cai (2005), One-sided confidence intervals in discrete distributions,
|
||||
Journal of Statistical Planning and Inference 131, 63-88.
|
||||
</p>
|
||||
<p>
|
||||
Agresti, A. and Coull, B. A. (1998). Approximate is better than "exact"
|
||||
for interval estimation of binomial proportions. Amer. Statist. 52 119-126.
|
||||
</p>
|
||||
<p>
|
||||
Clopper, C. J. and Pearson, E. S. (1934). The use of confidence or fiducial
|
||||
limits illustrated in the case of the binomial. Biometrika 26 404-413.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.binomial_dist.upper_bound_on_the_success_fract"></a></span><a class="link" href="binomial_dist.html#math_toolkit.dist_ref.dists.binomial_dist.upper_bound_on_the_success_fract">Upper
|
||||
Bound on the Success Fraction</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_upper_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">trials</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span>
|
||||
<span class="emphasis"><em>unspecified-type</em></span> <span class="identifier">method</span> <span class="special">=</span> <span class="identifier">clopper_pearson_exact_interval</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns an upper bound on the success fraction:
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">trials</span></dt>
|
||||
<dd><p>
|
||||
The total number of trials conducted.
|
||||
</p></dd>
|
||||
<dt><span class="term">successes</span></dt>
|
||||
<dd><p>
|
||||
The number of successes that occurred.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The largest acceptable probability that the true value of the success
|
||||
fraction is <span class="bold"><strong>greater than</strong></span> the value
|
||||
returned.
|
||||
</p></dd>
|
||||
<dt><span class="term">method</span></dt>
|
||||
<dd><p>
|
||||
An optional parameter that specifies the method to be used to compute
|
||||
the interval. Refer to the documentation for <code class="computeroutput"><span class="identifier">find_upper_bound_on_p</span></code>
|
||||
above for the meaning of the method options.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
For example, if you observe <span class="emphasis"><em>k</em></span> successes from <span class="emphasis"><em>n</em></span>
|
||||
trials the best estimate for the success fraction is simply <span class="emphasis"><em>k/n</em></span>,
|
||||
but if you want to be 95% sure that the true value is <span class="bold"><strong>less
|
||||
than</strong></span> some value, <span class="emphasis"><em>p<sub>max</sub></em></span>, then:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">p</span><sub>max</sub> <span class="special">=</span> <span class="identifier">binomial_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">find_upper_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">n</span><span class="special">,</span> <span class="identifier">k</span><span class="special">,</span> <span class="number">0.05</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
<a class="link" href="../../stat_tut/weg/binom_eg/binom_conf.html" title="Calculating Confidence Limits on the Frequency of Occurrence for a Binomial Distribution">See worked
|
||||
example.</a>
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
In order to obtain a two sided bound on the success fraction, you call
|
||||
both <code class="computeroutput"><span class="identifier">find_lower_bound_on_p</span></code>
|
||||
<span class="bold"><strong>and</strong></span> <code class="computeroutput"><span class="identifier">find_upper_bound_on_p</span></code>
|
||||
each with the same arguments.
|
||||
</p>
|
||||
<p>
|
||||
If the desired risk level that the true success fraction lies outside
|
||||
the bounds is α, then you pass α/2 to these functions.
|
||||
</p>
|
||||
<p>
|
||||
So for example a two sided 95% confidence interval would be obtained
|
||||
by passing α = 0.025 to each of the functions.
|
||||
</p>
|
||||
<p>
|
||||
<a class="link" href="../../stat_tut/weg/binom_eg/binom_conf.html" title="Calculating Confidence Limits on the Frequency of Occurrence for a Binomial Distribution">See worked
|
||||
example.</a>
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist.h5"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.binomial_dist.estimating_the_number_of_trials_"></a></span><a class="link" href="binomial_dist.html#math_toolkit.dist_ref.dists.binomial_dist.estimating_the_number_of_trials_">Estimating
|
||||
the Number of Trials Required for a Certain Number of Successes</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_minimum_number_of_trials</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">k</span><span class="special">,</span> <span class="comment">// number of events</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// success fraction</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">);</span> <span class="comment">// probability threshold</span>
|
||||
</pre>
|
||||
<p>
|
||||
This function estimates the minimum number of trials required to ensure
|
||||
that more than k events is observed with a level of risk <span class="emphasis"><em>alpha</em></span>
|
||||
that k or fewer events occur.
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">k</span></dt>
|
||||
<dd><p>
|
||||
The number of success observed.
|
||||
</p></dd>
|
||||
<dt><span class="term">p</span></dt>
|
||||
<dd><p>
|
||||
The probability of success for each trial.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The maximum acceptable probability that k events or fewer will be
|
||||
observed.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">binomial_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">find_number_of_trials</span><span class="special">(</span><span class="number">10</span><span class="special">,</span> <span class="number">0.5</span><span class="special">,</span> <span class="number">0.05</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the smallest number of trials we must conduct to be 95% sure of
|
||||
seeing 10 events that occur with frequency one half.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist.h6"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.binomial_dist.estimating_the_maximum_number_of"></a></span><a class="link" href="binomial_dist.html#math_toolkit.dist_ref.dists.binomial_dist.estimating_the_maximum_number_of">Estimating
|
||||
the Maximum Number of Trials to Ensure no more than a Certain Number of
|
||||
Successes</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_maximum_number_of_trials</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">k</span><span class="special">,</span> <span class="comment">// number of events</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// success fraction</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">);</span> <span class="comment">// probability threshold</span>
|
||||
</pre>
|
||||
<p>
|
||||
This function estimates the maximum number of trials we can conduct to
|
||||
ensure that k successes or fewer are observed, with a risk <span class="emphasis"><em>alpha</em></span>
|
||||
that more than k occur.
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">k</span></dt>
|
||||
<dd><p>
|
||||
The number of success observed.
|
||||
</p></dd>
|
||||
<dt><span class="term">p</span></dt>
|
||||
<dd><p>
|
||||
The probability of success for each trial.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The maximum acceptable probability that more than k events will be
|
||||
observed.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">binomial_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">find_maximum_number_of_trials</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">1e-6</span><span class="special">,</span> <span class="number">0.05</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the largest number of trials we can conduct and still be 95% certain
|
||||
of not observing any events that occur with one in a million frequency.
|
||||
This is typically used in failure analysis.
|
||||
</p>
|
||||
<p>
|
||||
<a class="link" href="../../stat_tut/weg/binom_eg/binom_size_eg.html" title="Estimating Sample Sizes for a Binomial Distribution.">See Worked
|
||||
Example.</a>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist.h7"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.binomial_dist.non_member_accessors"></a></span><a class="link" href="binomial_dist.html#math_toolkit.dist_ref.dists.binomial_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain for the random variable <span class="emphasis"><em>k</em></span> is <code class="computeroutput"><span class="number">0</span> <span class="special"><=</span> <span class="identifier">k</span> <span class="special"><=</span> <span class="identifier">N</span></code>, otherwise a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
is returned.
|
||||
</p>
|
||||
<p>
|
||||
It's worth taking a moment to define what these accessors actually mean
|
||||
in the context of this distribution:
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist.meaning_of_the_non_member_access"></a><p class="title"><b>Table 5.1. Meaning of the non-member accessors</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Meaning of the non-member accessors">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Meaning
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density
|
||||
Function</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The probability of obtaining <span class="bold"><strong>exactly k
|
||||
successes</strong></span> from n trials with success fraction p. For
|
||||
example:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">pdf</span><span class="special">(</span><span class="identifier">binomial</span><span class="special">(</span><span class="identifier">n</span><span class="special">,</span>
|
||||
<span class="identifier">p</span><span class="special">),</span>
|
||||
<span class="identifier">k</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution
|
||||
Function</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The probability of obtaining <span class="bold"><strong>k successes
|
||||
or fewer</strong></span> from n trials with success fraction p. For
|
||||
example:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">binomial</span><span class="special">(</span><span class="identifier">n</span><span class="special">,</span>
|
||||
<span class="identifier">p</span><span class="special">),</span>
|
||||
<span class="identifier">k</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.ccdf">Complement of
|
||||
the Cumulative Distribution Function</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The probability of obtaining <span class="bold"><strong>more than
|
||||
k successes</strong></span> from n trials with success fraction p.
|
||||
For example:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">binomial</span><span class="special">(</span><span class="identifier">n</span><span class="special">,</span>
|
||||
<span class="identifier">p</span><span class="special">),</span>
|
||||
<span class="identifier">k</span><span class="special">))</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The <span class="bold"><strong>greatest</strong></span> number of successes
|
||||
that may be observed from n trials with success fraction p, at
|
||||
probability P. Note that the value returned is a real-number,
|
||||
and not an integer. Depending on the use case you may want to
|
||||
take either the floor or ceiling of the result. For example:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">binomial</span><span class="special">(</span><span class="identifier">n</span><span class="special">,</span>
|
||||
<span class="identifier">p</span><span class="special">),</span>
|
||||
<span class="identifier">P</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.quantile_c">Quantile
|
||||
from the complement of the probability</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The <span class="bold"><strong>smallest</strong></span> number of successes
|
||||
that may be observed from n trials with success fraction p, at
|
||||
probability P. Note that the value returned is a real-number,
|
||||
and not an integer. Depending on the use case you may want to
|
||||
take either the floor or ceiling of the result. For example:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">binomial</span><span class="special">(</span><span class="identifier">n</span><span class="special">,</span>
|
||||
<span class="identifier">p</span><span class="special">),</span>
|
||||
<span class="identifier">P</span><span class="special">))</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break"><h5>
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist.h8"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.binomial_dist.examples"></a></span><a class="link" href="binomial_dist.html#math_toolkit.dist_ref.dists.binomial_dist.examples">Examples</a>
|
||||
</h5>
|
||||
<p>
|
||||
Various <a class="link" href="../../stat_tut/weg/binom_eg.html" title="Binomial Distribution Examples">worked examples</a>
|
||||
are available illustrating the use of the binomial distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist.h9"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.binomial_dist.accuracy"></a></span><a class="link" href="binomial_dist.html#math_toolkit.dist_ref.dists.binomial_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
This distribution is implemented using the incomplete beta functions <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a> and <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>,
|
||||
please refer to these functions for information on accuracy.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist.h10"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.binomial_dist.implementation"></a></span><a class="link" href="binomial_dist.html#math_toolkit.dist_ref.dists.binomial_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table <span class="emphasis"><em>p</em></span> is the probability that one
|
||||
trial will be successful (the success fraction), <span class="emphasis"><em>n</em></span>
|
||||
is the number of trials, <span class="emphasis"><em>k</em></span> is the number of successes,
|
||||
<span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Implementation is in terms of <a class="link" href="../../sf_beta/beta_derivative.html" title="Derivative of the Incomplete Beta Function">ibeta_derivative</a>:
|
||||
if <sub>n</sub>C<sub>k </sub> is the binomial coefficient of a and b, then we have:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/binomial_ref1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
Which can be evaluated as <code class="computeroutput"><span class="identifier">ibeta_derivative</span><span class="special">(</span><span class="identifier">k</span><span class="special">+</span><span class="number">1</span><span class="special">,</span> <span class="identifier">n</span><span class="special">-</span><span class="identifier">k</span><span class="special">+</span><span class="number">1</span><span class="special">,</span> <span class="identifier">p</span><span class="special">)</span> <span class="special">/</span>
|
||||
<span class="special">(</span><span class="identifier">n</span><span class="special">+</span><span class="number">1</span><span class="special">)</span></code>
|
||||
</p>
|
||||
<p>
|
||||
The function <a class="link" href="../../sf_beta/beta_derivative.html" title="Derivative of the Incomplete Beta Function">ibeta_derivative</a>
|
||||
is used here, since it has already been optimised for the lowest
|
||||
possible error - indeed this is really just a thin wrapper around
|
||||
part of the internals of the incomplete beta function.
|
||||
</p>
|
||||
<p>
|
||||
There are also various special cases: refer to the code for details.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation:
|
||||
</p>
|
||||
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">p</span> <span class="special">=</span> <span class="identifier">I</span><span class="special">[</span><span class="identifier">sub</span> <span class="number">1</span><span class="special">-</span><span class="identifier">p</span><span class="special">](</span><span class="identifier">n</span> <span class="special">-</span> <span class="identifier">k</span><span class="special">,</span> <span class="identifier">k</span> <span class="special">+</span> <span class="number">1</span><span class="special">)</span>
|
||||
<span class="special">=</span> <span class="number">1</span> <span class="special">-</span> <span class="identifier">I</span><span class="special">[</span><span class="identifier">sub</span> <span class="identifier">p</span><span class="special">](</span><span class="identifier">k</span> <span class="special">+</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">n</span> <span class="special">-</span> <span class="identifier">k</span><span class="special">)</span>
|
||||
<span class="special">=</span> <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a><span class="special">(</span><span class="identifier">k</span> <span class="special">+</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">n</span> <span class="special">-</span> <span class="identifier">k</span><span class="special">,</span> <span class="identifier">p</span><span class="special">)</span></pre>
|
||||
<p>
|
||||
There are also various special cases: refer to the code for details.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>(k
|
||||
+ 1, n - k, p)
|
||||
</p>
|
||||
<p>
|
||||
There are also various special cases: refer to the code for details.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Since the cdf is non-linear in variate <span class="emphasis"><em>k</em></span>
|
||||
none of the inverse incomplete beta functions can be used here.
|
||||
Instead the quantile is found numerically using a derivative
|
||||
free method (<a class="link" href="../../roots/roots_noderiv/TOMS748.html" title="Algorithm TOMS 748: Alefeld, Potra and Shi: Enclosing zeros of continuous functions">TOMS
|
||||
748 algorithm</a>).
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Found numerically as above.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">p</span> <span class="special">*</span>
|
||||
<span class="identifier">n</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">p</span> <span class="special">*</span>
|
||||
<span class="identifier">n</span> <span class="special">*</span>
|
||||
<span class="special">(</span><span class="number">1</span><span class="special">-</span><span class="identifier">p</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">floor</span><span class="special">(</span><span class="identifier">p</span> <span class="special">*</span>
|
||||
<span class="special">(</span><span class="identifier">n</span>
|
||||
<span class="special">+</span> <span class="number">1</span><span class="special">))</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">(</span><span class="number">1</span>
|
||||
<span class="special">-</span> <span class="number">2</span>
|
||||
<span class="special">*</span> <span class="identifier">p</span><span class="special">)</span> <span class="special">/</span>
|
||||
<span class="identifier">sqrt</span><span class="special">(</span><span class="identifier">n</span> <span class="special">*</span>
|
||||
<span class="identifier">p</span> <span class="special">*</span>
|
||||
<span class="special">(</span><span class="number">1</span>
|
||||
<span class="special">-</span> <span class="identifier">p</span><span class="special">))</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="number">3</span> <span class="special">-</span>
|
||||
<span class="special">(</span><span class="number">6</span>
|
||||
<span class="special">/</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">+</span>
|
||||
<span class="special">(</span><span class="number">1</span>
|
||||
<span class="special">/</span> <span class="special">(</span><span class="identifier">n</span> <span class="special">*</span>
|
||||
<span class="identifier">p</span> <span class="special">*</span>
|
||||
<span class="special">(</span><span class="number">1</span>
|
||||
<span class="special">-</span> <span class="identifier">p</span><span class="special">)))</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">(</span><span class="number">1</span>
|
||||
<span class="special">-</span> <span class="number">6</span>
|
||||
<span class="special">*</span> <span class="identifier">p</span>
|
||||
<span class="special">*</span> <span class="identifier">q</span><span class="special">)</span> <span class="special">/</span>
|
||||
<span class="special">(</span><span class="identifier">n</span>
|
||||
<span class="special">*</span> <span class="identifier">p</span>
|
||||
<span class="special">*</span> <span class="identifier">q</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
parameter estimation
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The member functions <code class="computeroutput"><span class="identifier">find_upper_bound_on_p</span></code>
|
||||
<code class="computeroutput"><span class="identifier">find_lower_bound_on_p</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">find_number_of_trials</span></code>
|
||||
are implemented in terms of the inverse incomplete beta functions
|
||||
<a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibetac_inv</a>,
|
||||
<a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_inv</a>,
|
||||
and <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibetac_invb</a>
|
||||
respectively
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.binomial_dist.h11"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.binomial_dist.references"></a></span><a class="link" href="binomial_dist.html#math_toolkit.dist_ref.dists.binomial_dist.references">References</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://mathworld.wolfram.com/BinomialDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Binomial Distribution." From MathWorld--A Wolfram
|
||||
Web Resource</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://en.wikipedia.org/wiki/Beta_distribution" target="_top">Wikipedia
|
||||
binomial distribution</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda366i.htm" target="_top">NIST
|
||||
Explorary Data Analysis</a>.
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="beta_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="cauchy_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,305 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Cauchy-Lorentz Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="binomial_dist.html" title="Binomial Distribution">
|
||||
<link rel="next" href="chi_squared_dist.html" title="Chi Squared Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="binomial_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="chi_squared_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.cauchy_dist"></a><a class="link" href="cauchy_dist.html" title="Cauchy-Lorentz Distribution">Cauchy-Lorentz
|
||||
Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">cauchy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<pre class="programlisting"><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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">cauchy_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">cauchy_distribution</span><span class="special"><></span> <span class="identifier">cauchy</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">cauchy_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">cauchy_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</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="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<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="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Cauchy_distribution" target="_top">Cauchy-Lorentz
|
||||
distribution</a> is named after Augustin Cauchy and Hendrik Lorentz.
|
||||
It is a <a href="http://en.wikipedia.org/wiki/Probability_distribution" target="_top">continuous
|
||||
probability distribution</a> with <a href="http://en.wikipedia.org/wiki/Probability_distribution" target="_top">probability
|
||||
distribution function PDF</a> given by:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/cauchy_ref1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
The location parameter x<sub>0</sub>   is the location of the peak of the distribution
|
||||
(the mode of the distribution), while the scale parameter γ   specifies half
|
||||
the width of the PDF at half the maximum height. If the location is zero,
|
||||
and the scale 1, then the result is a standard Cauchy distribution.
|
||||
</p>
|
||||
<p>
|
||||
The distribution is important in physics as it is the solution to the differential
|
||||
equation describing forced resonance, while in spectroscopy it is the description
|
||||
of the line shape of spectral lines.
|
||||
</p>
|
||||
<p>
|
||||
The following graph shows how the distributions moves as the location parameter
|
||||
changes:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/cauchy_pdf1.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
While the following graph shows how the shape (scale) parameter alters
|
||||
the distribution:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/cauchy_pdf2.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.cauchy_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.cauchy_dist.member_functions"></a></span><a class="link" href="cauchy_dist.html#math_toolkit.dist_ref.dists.cauchy_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">cauchy_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</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>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a Cauchy distribution, with location parameter <span class="emphasis"><em>location</em></span>
|
||||
and scale parameter <span class="emphasis"><em>scale</em></span>. When these parameters take
|
||||
their default values (location = 0, scale = 1) then the result is a Standard
|
||||
Cauchy Distribution.
|
||||
</p>
|
||||
<p>
|
||||
Requires scale > 0, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the location parameter of the distribution.
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the scale parameter of the distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.cauchy_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.cauchy_dist.non_member_accessors"></a></span><a class="link" href="cauchy_dist.html#math_toolkit.dist_ref.dists.cauchy_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
Note however that the Cauchy distribution does not have a mean, standard
|
||||
deviation, etc. See <a class="link" href="../../pol_ref/assert_undefined.html" title="Mathematically Undefined Function Policies">mathematically
|
||||
undefined function</a> to control whether these should fail to compile
|
||||
with a BOOST_STATIC_ASSERTION_FAILURE, which is the default.
|
||||
</p>
|
||||
<p>
|
||||
Alternately, the functions <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.sd">standard deviation</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.variance">variance</a>, <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>
|
||||
and <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess</a>
|
||||
will all return a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if called.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [-[max_value], +[min_value]].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.cauchy_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.cauchy_dist.accuracy"></a></span><a class="link" href="cauchy_dist.html#math_toolkit.dist_ref.dists.cauchy_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The Cauchy distribution is implemented in terms of the standard library
|
||||
<code class="computeroutput"><span class="identifier">tan</span></code> and <code class="computeroutput"><span class="identifier">atan</span></code>
|
||||
functions, and as such should have very low error rates.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.cauchy_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.cauchy_dist.implementation"></a></span><a class="link" href="cauchy_dist.html#math_toolkit.dist_ref.dists.cauchy_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table x<sub>0 </sub> is the location parameter of the distribution,
|
||||
γ   is its scale parameter, <span class="emphasis"><em>x</em></span> is the random variate,
|
||||
<span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = 1 / (π * γ * (1 + ((x - x<sub>0 </sub>) / γ)<sup>2</sup>)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf and its complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The cdf is normally given by:
|
||||
</p>
|
||||
<p>
|
||||
p = 0.5 + atan(x)/π
|
||||
</p>
|
||||
<p>
|
||||
But that suffers from cancellation error as x -> -∞. So recall
|
||||
that for <code class="computeroutput"><span class="identifier">x</span> <span class="special"><</span>
|
||||
<span class="number">0</span></code>:
|
||||
</p>
|
||||
<p>
|
||||
atan(x) = -π/2 - atan(1/x)
|
||||
</p>
|
||||
<p>
|
||||
Substituting into the above we get:
|
||||
</p>
|
||||
<p>
|
||||
p = -atan(1/x) ; x < 0
|
||||
</p>
|
||||
<p>
|
||||
So the procedure is to calculate the cdf for -fabs(x) using the
|
||||
above formula. Note that to factor in the location and scale
|
||||
parameters you must substitute (x - x<sub>0 </sub>) / γ   for x in the above.
|
||||
</p>
|
||||
<p>
|
||||
This procedure yields the smaller of <span class="emphasis"><em>p</em></span> and
|
||||
<span class="emphasis"><em>q</em></span>, so the result may need subtracting from
|
||||
1 depending on whether we want the complement or not, and whether
|
||||
<span class="emphasis"><em>x</em></span> is less than x<sub>0 </sub> or not.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The same procedure is used irrespective of whether we're starting
|
||||
from the probability or its complement. First the argument <span class="emphasis"><em>p</em></span>
|
||||
is reduced to the range [-0.5, 0.5], then the relation
|
||||
</p>
|
||||
<p>
|
||||
x = x<sub>0 </sub> ± γ   / tan(π * p)
|
||||
</p>
|
||||
<p>
|
||||
is used to obtain the result. Whether we're adding or subtracting
|
||||
from x<sub>0 </sub> is determined by whether we're starting from the complement
|
||||
or not.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The location parameter.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.cauchy_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.cauchy_dist.references"></a></span><a class="link" href="cauchy_dist.html#math_toolkit.dist_ref.dists.cauchy_dist.references">References</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://en.wikipedia.org/wiki/Cauchy_distribution" target="_top">Cauchy-Lorentz
|
||||
distribution</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3663.htm" target="_top">NIST
|
||||
Exploratory Data Analysis</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://mathworld.wolfram.com/CauchyDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Cauchy Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="binomial_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="chi_squared_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,411 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chi Squared Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="cauchy_dist.html" title="Cauchy-Lorentz Distribution">
|
||||
<link rel="next" href="exp_dist.html" title="Exponential Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="cauchy_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="exp_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.chi_squared_dist"></a><a class="link" href="chi_squared_dist.html" title="Chi Squared Distribution">Chi Squared
|
||||
Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">chi_squared</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">chi_squared_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">chi_squared_distribution</span><span class="special"><></span> <span class="identifier">chi_squared</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">chi_squared_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Constructor:</span>
|
||||
<span class="identifier">chi_squared_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">i</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// Accessor to parameter:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Parameter estimation:</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_degrees_of_freedom</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">difference_from_mean</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">sd</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">hint</span> <span class="special">=</span> <span class="number">100</span><span class="special">);</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The Chi-Squared distribution is one of the most widely used distributions
|
||||
in statistical tests. If χ<sub>i</sub>   are ν  
|
||||
independent, normally distributed random
|
||||
variables with means μ<sub>i</sub>   and variances σ<sub>i</sub><sup>2</sup>, then the random variable:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/chi_squ_ref1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
is distributed according to the Chi-Squared distribution.
|
||||
</p>
|
||||
<p>
|
||||
The Chi-Squared distribution is a special case of the gamma distribution
|
||||
and has a single parameter ν   that specifies the number of degrees of freedom.
|
||||
The following graph illustrates how the distribution changes for different
|
||||
values of ν:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/chi_squared_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.chi_squared_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.chi_squared_dist.member_functions"></a></span><a class="link" href="chi_squared_dist.html#math_toolkit.dist_ref.dists.chi_squared_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">chi_squared_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a Chi-Squared distribution with <span class="emphasis"><em>v</em></span> degrees
|
||||
of freedom.
|
||||
</p>
|
||||
<p>
|
||||
Requires v > 0, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>v</em></span> from which this object was
|
||||
constructed.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_degrees_of_freedom</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">difference_from_variance</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">hint</span> <span class="special">=</span> <span class="number">100</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Estimates the sample size required to detect a difference from a nominal
|
||||
variance in a Chi-Squared test for equal standard deviations.
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">difference_from_variance</span></dt>
|
||||
<dd><p>
|
||||
The difference from the assumed nominal variance that is to be detected:
|
||||
Note that the sign of this value is critical, see below.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The maximum acceptable risk of rejecting the null hypothesis when
|
||||
it is in fact true.
|
||||
</p></dd>
|
||||
<dt><span class="term">beta</span></dt>
|
||||
<dd><p>
|
||||
The maximum acceptable risk of falsely failing to reject the null
|
||||
hypothesis.
|
||||
</p></dd>
|
||||
<dt><span class="term">variance</span></dt>
|
||||
<dd><p>
|
||||
The nominal variance being tested against.
|
||||
</p></dd>
|
||||
<dt><span class="term">hint</span></dt>
|
||||
<dd><p>
|
||||
An optional hint on where to start looking for a result: the current
|
||||
sample size would be a good choice.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
Note that this calculation works with <span class="emphasis"><em>variances</em></span> and
|
||||
not <span class="emphasis"><em>standard deviations</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
The sign of the parameter <span class="emphasis"><em>difference_from_variance</em></span>
|
||||
is important: the Chi Squared distribution is asymmetric, and the caller
|
||||
must decide in advance whether they are testing for a variance greater
|
||||
than a nominal value (positive <span class="emphasis"><em>difference_from_variance</em></span>)
|
||||
or testing for a variance less than a nominal value (negative <span class="emphasis"><em>difference_from_variance</em></span>).
|
||||
If the latter, then obviously it is a requirement that <code class="computeroutput"><span class="identifier">variance</span>
|
||||
<span class="special">+</span> <span class="identifier">difference_from_variance</span>
|
||||
<span class="special">></span> <span class="number">0</span></code>,
|
||||
since no sample can have a negative variance!
|
||||
</p>
|
||||
<p>
|
||||
This procedure uses the method in Diamond, W. J. (1989). Practical Experiment
|
||||
Designs, Van-Nostrand Reinhold, New York.
|
||||
</p>
|
||||
<p>
|
||||
See also section on Sample sizes required in <a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc232.htm" target="_top">the
|
||||
NIST Engineering Statistics Handbook, Section 7.2.3.2</a>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.chi_squared_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.chi_squared_dist.non_member_accessors"></a></span><a class="link" href="chi_squared_dist.html#math_toolkit.dist_ref.dists.chi_squared_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
(We have followed the usual restriction of the mode to degrees of freedom
|
||||
>= 2, but note that the maximum of the pdf is actually zero for degrees
|
||||
of freedom from 2 down to 0, and provide an extended definition that would
|
||||
avoid a discontinuity in the mode as alternative code in a comment).
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [0, +∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.chi_squared_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.chi_squared_dist.examples"></a></span><a class="link" href="chi_squared_dist.html#math_toolkit.dist_ref.dists.chi_squared_dist.examples">Examples</a>
|
||||
</h5>
|
||||
<p>
|
||||
Various <a class="link" href="../../stat_tut/weg/cs_eg.html" title="Chi Squared Distribution Examples">worked examples</a>
|
||||
are available illustrating the use of the Chi Squared Distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.chi_squared_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.chi_squared_dist.accuracy"></a></span><a class="link" href="chi_squared_dist.html#math_toolkit.dist_ref.dists.chi_squared_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The Chi-Squared distribution is implemented in terms of the <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">incomplete
|
||||
gamma functions</a>: please refer to the accuracy data for those functions.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.chi_squared_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.chi_squared_dist.implementation"></a></span><a class="link" href="chi_squared_dist.html#math_toolkit.dist_ref.dists.chi_squared_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table <span class="emphasis"><em>v</em></span> is the number of degrees
|
||||
of freedom of the distribution, <span class="emphasis"><em>x</em></span> is the random variate,
|
||||
<span class="emphasis"><em>p</em></span> is the probability, and <span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = <a class="link" href="../../sf_gamma/gamma_derivatives.html" title="Derivative of the Incomplete Gamma Function">gamma_p_derivative</a>(v
|
||||
/ 2, x / 2) / 2
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: p = <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_p</a>(v
|
||||
/ 2, x / 2)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_q</a>(v
|
||||
/ 2, x / 2)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = 2 * <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_p_inv</a>(v
|
||||
/ 2, p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = 2 * <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_q_inv</a>(v
|
||||
/ 2, p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
v
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
2v
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
v - 2 (if v >= 2)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
2 * sqrt(2 / v) == sqrt(8 / v)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
3 + 12 / v
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12 / v
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.chi_squared_dist.h5"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.chi_squared_dist.references"></a></span><a class="link" href="chi_squared_dist.html#math_toolkit.dist_ref.dists.chi_squared_dist.references">References</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3666.htm" target="_top">NIST
|
||||
Exploratory Data Analysis</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://en.wikipedia.org/wiki/Chi-square_distribution" target="_top">Chi-square
|
||||
distribution</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://mathworld.wolfram.com/Chi-SquaredDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Chi-Squared Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="cauchy_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="exp_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,328 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Exponential Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="chi_squared_dist.html" title="Chi Squared Distribution">
|
||||
<link rel="next" href="extreme_dist.html" title="Extreme Value Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="chi_squared_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="extreme_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.exp_dist"></a><a class="link" href="exp_dist.html" title="Exponential Distribution">Exponential Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">exponential</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<pre class="programlisting"><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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">exponential_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">exponential_distribution</span><span class="special"><></span> <span class="identifier">exponential</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">exponential_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">exponential_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">lambda</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
|
||||
|
||||
<span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Exponential_distribution" target="_top">exponential
|
||||
distribution</a> is a <a href="http://en.wikipedia.org/wiki/Probability_distribution" target="_top">continuous
|
||||
probability distribution</a> with PDF:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/exponential_dist_ref1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
It is often used to model the time between independent events that happen
|
||||
at a constant average rate.
|
||||
</p>
|
||||
<p>
|
||||
The following graph shows how the distribution changes for different values
|
||||
of the rate parameter lambda:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/exponential_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.exp_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.exp_dist.member_functions"></a></span><a class="link" href="exp_dist.html#math_toolkit.dist_ref.dists.exp_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">exponential_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">lambda</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs an <a href="http://en.wikipedia.org/wiki/Exponential_distribution" target="_top">Exponential
|
||||
distribution</a> with parameter <span class="emphasis"><em>lambda</em></span>. Lambda
|
||||
is defined as the reciprocal of the scale parameter.
|
||||
</p>
|
||||
<p>
|
||||
Requires lambda > 0, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Accessor function returns the lambda parameter of the distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.exp_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.exp_dist.non_member_accessors"></a></span><a class="link" href="exp_dist.html#math_toolkit.dist_ref.dists.exp_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [0, +∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.exp_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.exp_dist.accuracy"></a></span><a class="link" href="exp_dist.html#math_toolkit.dist_ref.dists.exp_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The exponential distribution is implemented in terms of the standard library
|
||||
functions <code class="computeroutput"><span class="identifier">exp</span></code>, <code class="computeroutput"><span class="identifier">log</span></code>, <code class="computeroutput"><span class="identifier">log1p</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">expm1</span></code> and as such should
|
||||
have very low error rates.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.exp_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.exp_dist.implementation"></a></span><a class="link" href="exp_dist.html#math_toolkit.dist_ref.dists.exp_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table λ is the parameter lambda of the distribution, <span class="emphasis"><em>x</em></span>
|
||||
is the random variate, <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q
|
||||
= 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = λ * exp(-λ * x)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: p = 1 - exp(-x * λ) = -expm1(-x * λ)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = exp(-x * λ)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = -log(1-p) / λ = -log1p(-p) / λ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = -log(q) / λ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1/λ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
standard deviation
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1/λ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
0
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
2
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
9
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
6
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.exp_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.exp_dist.references"></a></span><a class="link" href="exp_dist.html#math_toolkit.dist_ref.dists.exp_dist.references">references</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://mathworld.wolfram.com/ExponentialDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Exponential Distribution." From MathWorld--A Wolfram
|
||||
Web Resource</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://documents.wolfram.com/calccenter/Functions/ListsMatrices/Statistics/ExponentialDistribution.html" target="_top">Wolfram
|
||||
Mathematica calculator</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3667.htm" target="_top">NIST
|
||||
Exploratory Data Analysis</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://en.wikipedia.org/wiki/Exponential_distribution" target="_top">Wikipedia
|
||||
Exponential distribution</a>
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
(See also the reference documentation for the related <a class="link" href="extreme_dist.html" title="Extreme Value Distribution">Extreme
|
||||
Distributions</a>.)
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
|
||||
<a href="http://www.worldscibooks.com/mathematics/p191.html" target="_top">Extreme
|
||||
Value Distributions, Theory and Applications Samuel Kotz & Saralees
|
||||
Nadarajah</a> discuss the relationship of the types of extreme
|
||||
value distributions.
|
||||
</li></ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="chi_squared_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="extreme_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,331 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Extreme Value Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="exp_dist.html" title="Exponential Distribution">
|
||||
<link rel="next" href="f_dist.html" title="F Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="exp_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="f_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.extreme_dist"></a><a class="link" href="extreme_dist.html" title="Extreme Value Distribution">Extreme Value
|
||||
Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">extreme</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<pre class="programlisting"><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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">extreme_value_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">extreme_value_distribution</span><span class="special"><></span> <span class="identifier">extreme_value</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">extreme_value_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">extreme_value_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</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="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
There are various <a href="http://mathworld.wolfram.com/ExtremeValueDistribution.html" target="_top">extreme
|
||||
value distributions</a> : this implementation represents the maximum
|
||||
case, and is variously known as a Fisher-Tippett distribution, a log-Weibull
|
||||
distribution or a Gumbel distribution.
|
||||
</p>
|
||||
<p>
|
||||
Extreme value theory is important for assessing risk for highly unusual
|
||||
events, such as 100-year floods.
|
||||
</p>
|
||||
<p>
|
||||
More information can be found on the <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda366g.htm" target="_top">NIST</a>,
|
||||
<a href="http://en.wikipedia.org/wiki/Extreme_value_distribution" target="_top">Wikipedia</a>,
|
||||
<a href="http://mathworld.wolfram.com/ExtremeValueDistribution.html" target="_top">Mathworld</a>,
|
||||
and <a href="http://en.wikipedia.org/wiki/Extreme_value_theory" target="_top">Extreme
|
||||
value theory</a> websites.
|
||||
</p>
|
||||
<p>
|
||||
The relationship of the types of extreme value distributions, of which
|
||||
this is but one, is discussed by <a href="http://www.worldscibooks.com/mathematics/p191.html" target="_top">Extreme
|
||||
Value Distributions, Theory and Applications Samuel Kotz & Saralees
|
||||
Nadarajah</a>.
|
||||
</p>
|
||||
<p>
|
||||
The distribution has a PDF given by:
|
||||
</p>
|
||||
<p>
|
||||
f(x) = (1/scale) e<sup>-(x-location)/scale</sup> e<sup>-e<sup>-(x-location)/scale</sup></sup>
|
||||
</p>
|
||||
<p>
|
||||
Which in the standard case (scale = 1, location = 0) reduces to:
|
||||
</p>
|
||||
<p>
|
||||
f(x) = e<sup>-x</sup>e<sup>-e<sup>-x</sup></sup>
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates how the PDF varies with the location parameter:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/extreme_value_pdf1.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
And this graph illustrates how the PDF varies with the shape parameter:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/extreme_value_pdf2.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.extreme_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.extreme_dist.member_functions"></a></span><a class="link" href="extreme_dist.html#math_toolkit.dist_ref.dists.extreme_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">extreme_value_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</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>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs an Extreme Value distribution with the specified location and
|
||||
scale parameters.
|
||||
</p>
|
||||
<p>
|
||||
Requires <code class="computeroutput"><span class="identifier">scale</span> <span class="special">></span>
|
||||
<span class="number">0</span></code>, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the location parameter of the distribution.
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the scale parameter of the distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.extreme_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.extreme_dist.non_member_accessors"></a></span><a class="link" href="extreme_dist.html#math_toolkit.dist_ref.dists.extreme_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random parameter is [-∞, +∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.extreme_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.extreme_dist.accuracy"></a></span><a class="link" href="extreme_dist.html#math_toolkit.dist_ref.dists.extreme_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The extreme value distribution is implemented in terms of the standard
|
||||
library <code class="computeroutput"><span class="identifier">exp</span></code> and <code class="computeroutput"><span class="identifier">log</span></code> functions and as such should have
|
||||
very low error rates.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.extreme_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.extreme_dist.implementation"></a></span><a class="link" href="extreme_dist.html#math_toolkit.dist_ref.dists.extreme_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table: <span class="emphasis"><em>a</em></span> is the location parameter,
|
||||
<span class="emphasis"><em>b</em></span> is the scale parameter, <span class="emphasis"><em>x</em></span> is
|
||||
the random variate, <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q
|
||||
= 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = exp((a-x)/b) * exp(-exp((a-x)/b)) /
|
||||
b
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: p = exp(-exp((a-x)/b))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = -expm1(-exp((a-x)/b))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: a - log(-log(p)) * b
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: a - log(-log1p(-q)) * b
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
a + <a href="http://en.wikipedia.org/wiki/Euler-Mascheroni_constant" target="_top">Euler-Mascheroni-constant</a>
|
||||
* b
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
standard deviation
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
pi * b / sqrt(6)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The same as the location parameter <span class="emphasis"><em>a</em></span>.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12 * sqrt(6) * zeta(3) / pi<sup>3</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
27 / 5
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis - 3 or 12 / 5
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="exp_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="f_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,434 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>F Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="extreme_dist.html" title="Extreme Value Distribution">
|
||||
<link rel="next" href="gamma_dist.html" title="Gamma (and Erlang) Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="extreme_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="gamma_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.f_dist"></a><a class="link" href="f_dist.html" title="F Distribution">F Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">fisher_f</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">fisher_f_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">fisher_f_distribution</span><span class="special"><></span> <span class="identifier">fisher_f</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">fisher_f_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Construct:</span>
|
||||
<span class="identifier">fisher_f_distribution</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">RealType</span><span class="special">&</span> <span class="identifier">i</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">RealType</span><span class="special">&</span> <span class="identifier">j</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// Accessors:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom1</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom2</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">//namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The F distribution is a continuous distribution that arises when testing
|
||||
whether two samples have the same variance. If χ<sup>2</sup><sub>m</sub>   and χ<sup>2</sup><sub>n</sub>   are independent
|
||||
variates each distributed as Chi-Squared with <span class="emphasis"><em>m</em></span> and
|
||||
<span class="emphasis"><em>n</em></span> degrees of freedom, then the test statistic:
|
||||
</p>
|
||||
<p>
|
||||
F<sub>n,m</sub>   = (χ<sup>2</sup><sub>n</sub>   / n) / (χ<sup>2</sup><sub>m</sub>   / m)
|
||||
</p>
|
||||
<p>
|
||||
Is distributed over the range [0, ∞] with an F distribution, and has the
|
||||
PDF:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/fisher_pdf.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates how the PDF varies depending on the two
|
||||
degrees of freedom parameters.
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/fisher_f_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.f_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.f_dist.member_functions"></a></span><a class="link" href="f_dist.html#math_toolkit.dist_ref.dists.f_dist.member_functions">Member Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">fisher_f_distribution</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">RealType</span><span class="special">&</span> <span class="identifier">df1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">RealType</span><span class="special">&</span> <span class="identifier">df2</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs an F-distribution with numerator degrees of freedom <span class="emphasis"><em>df1</em></span>
|
||||
and denominator degrees of freedom <span class="emphasis"><em>df2</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Requires that <span class="emphasis"><em>df1</em></span> and <span class="emphasis"><em>df2</em></span> are
|
||||
both greater than zero, otherwise <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
is called.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom1</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the numerator degrees of freedom parameter of the distribution.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom2</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the denominator degrees of freedom parameter of the distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.f_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.f_dist.non_member_accessors"></a></span><a class="link" href="f_dist.html#math_toolkit.dist_ref.dists.f_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [0, +∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.f_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.f_dist.examples"></a></span><a class="link" href="f_dist.html#math_toolkit.dist_ref.dists.f_dist.examples">Examples</a>
|
||||
</h5>
|
||||
<p>
|
||||
Various <a class="link" href="../../stat_tut/weg/f_eg.html" title="F Distribution Examples">worked examples</a>
|
||||
are available illustrating the use of the F Distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.f_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.f_dist.accuracy"></a></span><a class="link" href="f_dist.html#math_toolkit.dist_ref.dists.f_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The normal distribution is implemented in terms of the <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">incomplete
|
||||
beta function</a> and its <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">inverses</a>,
|
||||
refer to those functions for accuracy data.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.f_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.f_dist.implementation"></a></span><a class="link" href="f_dist.html#math_toolkit.dist_ref.dists.f_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table <span class="emphasis"><em>v1</em></span> and <span class="emphasis"><em>v2</em></span>
|
||||
are the first and second degrees of freedom parameters of the distribution,
|
||||
<span class="emphasis"><em>x</em></span> is the random variate, <span class="emphasis"><em>p</em></span> is
|
||||
the probability, and <span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The usual form of the PDF is given by:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/fisher_pdf.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
However, that form is hard to evaluate directly without incurring
|
||||
problems with either accuracy or numeric overflow.
|
||||
</p>
|
||||
<p>
|
||||
Direct differentiation of the CDF expressed in terms of the incomplete
|
||||
beta function
|
||||
</p>
|
||||
<p>
|
||||
led to the following two formulas:
|
||||
</p>
|
||||
<p>
|
||||
f<sub>v1,v2</sub>(x) = y * <a class="link" href="../../sf_beta/beta_derivative.html" title="Derivative of the Incomplete Beta Function">ibeta_derivative</a>(v2
|
||||
/ 2, v1 / 2, v2 / (v2 + v1 * x))
|
||||
</p>
|
||||
<p>
|
||||
with y = (v2 * v1) / ((v2 + v1 * x) * (v2 + v1 * x))
|
||||
</p>
|
||||
<p>
|
||||
and
|
||||
</p>
|
||||
<p>
|
||||
f<sub>v1,v2</sub>(x) = y * <a class="link" href="../../sf_beta/beta_derivative.html" title="Derivative of the Incomplete Beta Function">ibeta_derivative</a>(v1
|
||||
/ 2, v2 / 2, v1 * x / (v2 + v1 * x))
|
||||
</p>
|
||||
<p>
|
||||
with y = (z * v1 - x * v1 * v1) / z<sup>2</sup>
|
||||
</p>
|
||||
<p>
|
||||
and z = v2 + v1 * x
|
||||
</p>
|
||||
<p>
|
||||
The first of these is used for v1 * x > v2, otherwise the
|
||||
second is used.
|
||||
</p>
|
||||
<p>
|
||||
The aim is to keep the <span class="emphasis"><em>x</em></span> argument to <a class="link" href="../../sf_beta/beta_derivative.html" title="Derivative of the Incomplete Beta Function">ibeta_derivative</a>
|
||||
away from 1 to avoid rounding error.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relations:
|
||||
</p>
|
||||
<p>
|
||||
p = <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>(v1
|
||||
/ 2, v2 / 2, v1 * x / (v2 + v1 * x))
|
||||
</p>
|
||||
<p>
|
||||
and
|
||||
</p>
|
||||
<p>
|
||||
p = <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>(v2
|
||||
/ 2, v1 / 2, v2 / (v2 + v1 * x))
|
||||
</p>
|
||||
<p>
|
||||
The first is used for v1 * x > v2, otherwise the second is
|
||||
used.
|
||||
</p>
|
||||
<p>
|
||||
The aim is to keep the <span class="emphasis"><em>x</em></span> argument to <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a> well
|
||||
away from 1 to avoid rounding error.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relations:
|
||||
</p>
|
||||
<p>
|
||||
p = <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>(v1
|
||||
/ 2, v2 / 2, v1 * x / (v2 + v1 * x))
|
||||
</p>
|
||||
<p>
|
||||
and
|
||||
</p>
|
||||
<p>
|
||||
p = <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>(v2
|
||||
/ 2, v1 / 2, v2 / (v2 + v1 * x))
|
||||
</p>
|
||||
<p>
|
||||
The first is used for v1 * x < v2, otherwise the second is
|
||||
used.
|
||||
</p>
|
||||
<p>
|
||||
The aim is to keep the <span class="emphasis"><em>x</em></span> argument to <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a> well
|
||||
away from 1 to avoid rounding error.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation:
|
||||
</p>
|
||||
<p>
|
||||
x = v2 * a / (v1 * b)
|
||||
</p>
|
||||
<p>
|
||||
where:
|
||||
</p>
|
||||
<p>
|
||||
a = <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_inv</a>(v1
|
||||
/ 2, v2 / 2, p)
|
||||
</p>
|
||||
<p>
|
||||
and
|
||||
</p>
|
||||
<p>
|
||||
b = 1 - a
|
||||
</p>
|
||||
<p>
|
||||
Quantities <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span>
|
||||
are both computed by <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_inv</a>
|
||||
without the subtraction implied above.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
<p>
|
||||
from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation:
|
||||
</p>
|
||||
<p>
|
||||
x = v2 * a / (v1 * b)
|
||||
</p>
|
||||
<p>
|
||||
where
|
||||
</p>
|
||||
<p>
|
||||
a = <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibetac_inv</a>(v1
|
||||
/ 2, v2 / 2, p)
|
||||
</p>
|
||||
<p>
|
||||
and
|
||||
</p>
|
||||
<p>
|
||||
b = 1 - a
|
||||
</p>
|
||||
<p>
|
||||
Quantities <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span>
|
||||
are both computed by <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibetac_inv</a>
|
||||
without the subtraction implied above.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
v2 / (v2 - 2)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
2 * v2<sup>2 </sup> * (v1 + v2 - 2) / (v1 * (v2 - 2) * (v2 - 2) * (v2 - 4))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
v2 * (v1 - 2) / (v1 * (v2 + 2))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
2 * (v2 + 2 * v1 - 2) * sqrt((2 * v2 - 8) / (v1 * (v2 + v1 -
|
||||
2))) / (v2 - 6)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis and kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Refer to, <a href="http://mathworld.wolfram.com/F-Distribution.html" target="_top">Weisstein,
|
||||
Eric W. "F-Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="extreme_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="gamma_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,364 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Gamma (and Erlang) Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="f_dist.html" title="F Distribution">
|
||||
<link rel="next" href="geometric_dist.html" title="Geometric Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="f_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="geometric_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.gamma_dist"></a><a class="link" href="gamma_dist.html" title="Gamma (and Erlang) Distribution">Gamma (and
|
||||
Erlang) Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">gamma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">gamma_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">gamma_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">shape</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="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<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="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The gamma distribution is a continuous probability distribution. When the
|
||||
shape parameter is an integer then it is known as the Erlang Distribution.
|
||||
It is also closely related to the Poisson and Chi Squared Distributions.
|
||||
</p>
|
||||
<p>
|
||||
When the shape parameter has an integer value, the distribution is the
|
||||
<a href="http://en.wikipedia.org/wiki/Erlang_distribution" target="_top">Erlang distribution</a>.
|
||||
Since this can be produced by ensuring that the shape parameter has an
|
||||
integer value > 0, the Erlang distribution is not separately implemented.
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
To avoid potential confusion with the gamma functions, this distribution
|
||||
does not provide the typedef:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">gamma_distribution</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">gamma</span><span class="special">;</span></pre>
|
||||
<p>
|
||||
Instead if you want a double precision gamma distribution you can write
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">gamma_distribution</span><span class="special"><></span> <span class="identifier">my_gamma</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span></pre>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
For shape parameter <span class="emphasis"><em>k</em></span> and scale parameter θ   it is defined
|
||||
by the probability density function:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/gamma_dist_ref1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
Sometimes an alternative formulation is used: given parameters α  = k and
|
||||
β  = 1 / θ, then the distribution can be defined by the PDF:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/gamma_dist_ref2.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
In this form the inverse scale parameter is called a <span class="emphasis"><em>rate parameter</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Both forms are in common usage: this library uses the first definition
|
||||
throughout. Therefore to construct a Gamma Distribution from a <span class="emphasis"><em>rate
|
||||
parameter</em></span>, you should pass the reciprocal of the rate as the
|
||||
scale parameter.
|
||||
</p>
|
||||
<p>
|
||||
The following two graphs illustrate how the PDF of the gamma distribution
|
||||
varies as the parameters vary:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/gamma1_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/gamma2_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
The <span class="bold"><strong>Erlang Distribution</strong></span> is the same as
|
||||
the Gamma, but with the shape parameter an integer. It is often expressed
|
||||
using a <span class="emphasis"><em>rate</em></span> rather than a <span class="emphasis"><em>scale</em></span>
|
||||
as the second parameter (remember that the rate is the reciprocal of the
|
||||
scale).
|
||||
</p>
|
||||
<p>
|
||||
Internally the functions used to implement the Gamma Distribution are already
|
||||
optimised for small-integer arguments, so in general there should be no
|
||||
great loss of performance from using a Gamma Distribution rather than a
|
||||
dedicated Erlang Distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.gamma_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.gamma_dist.member_functions"></a></span><a class="link" href="gamma_dist.html#math_toolkit.dist_ref.dists.gamma_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">gamma_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">shape</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>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a gamma distribution with shape <span class="emphasis"><em>shape</em></span> and
|
||||
scale <span class="emphasis"><em>scale</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Requires that the shape and scale parameters are greater than zero, otherwise
|
||||
calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>shape</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>scale</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.gamma_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.gamma_dist.non_member_accessors"></a></span><a class="link" href="gamma_dist.html#math_toolkit.dist_ref.dists.gamma_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [0,+∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.gamma_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.gamma_dist.accuracy"></a></span><a class="link" href="gamma_dist.html#math_toolkit.dist_ref.dists.gamma_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The lognormal distribution is implemented in terms of the incomplete gamma
|
||||
functions <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_p</a> and
|
||||
<a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_q</a> and their inverses
|
||||
<a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_p_inv</a> and
|
||||
<a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_q_inv</a>: refer
|
||||
to the accuracy data for those functions for more information.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.gamma_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.gamma_dist.implementation"></a></span><a class="link" href="gamma_dist.html#math_toolkit.dist_ref.dists.gamma_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table <span class="emphasis"><em>k</em></span> is the shape parameter of
|
||||
the distribution, θ   is its scale parameter, <span class="emphasis"><em>x</em></span> is the
|
||||
random variate, <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q
|
||||
= 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = <a class="link" href="../../sf_gamma/gamma_derivatives.html" title="Derivative of the Incomplete Gamma Function">gamma_p_derivative</a>(k,
|
||||
x / θ) / θ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: p = <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_p</a>(k,
|
||||
x / θ)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_q</a>(k,
|
||||
x / θ)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = θ  * <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_p_inv</a>(k,
|
||||
p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = θ  * <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_q_inv</a>(k,
|
||||
p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
kθ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
kθ<sup>2</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(k-1)θ   for <span class="emphasis"><em>k>1</em></span> otherwise a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
2 / sqrt(k)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
3 + 6 / k
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
6 / k
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="f_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="geometric_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,841 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Geometric Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="gamma_dist.html" title="Gamma (and Erlang) Distribution">
|
||||
<link rel="next" href="hyperexponential_dist.html" title="Hyperexponential Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="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="hyperexponential_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.geometric_dist"></a><a class="link" href="geometric_dist.html" title="Geometric Distribution">Geometric
|
||||
Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">geometric</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">geometric_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">geometric_distribution</span><span class="special"><></span> <span class="identifier">geometric</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">geometric_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
<span class="comment">// Constructor from success_fraction:</span>
|
||||
<span class="identifier">geometric_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// Parameter accessors:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">success_fraction</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Bounds on success fraction:</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_lower_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">trials</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// alpha</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_upper_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">trials</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// alpha</span>
|
||||
|
||||
<span class="comment">// Estimate min/max number of trials:</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_minimum_number_of_trials</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">k</span><span class="special">,</span> <span class="comment">// Number of failures.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// Success fraction.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// Probability threshold alpha.</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_maximum_number_of_trials</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">k</span><span class="special">,</span> <span class="comment">// Number of failures.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// Success fraction.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// Probability threshold alpha.</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The class type <code class="computeroutput"><span class="identifier">geometric_distribution</span></code>
|
||||
represents a <a href="http://en.wikipedia.org/wiki/geometric_distribution" target="_top">geometric
|
||||
distribution</a>: it is used when there are exactly two mutually exclusive
|
||||
outcomes of a <a href="http://en.wikipedia.org/wiki/Bernoulli_trial" target="_top">Bernoulli
|
||||
trial</a>: these outcomes are labelled "success" and "failure".
|
||||
</p>
|
||||
<p>
|
||||
For <a href="http://en.wikipedia.org/wiki/Bernoulli_trial" target="_top">Bernoulli
|
||||
trials</a> each with success fraction <span class="emphasis"><em>p</em></span>, the geometric
|
||||
distribution gives the probability of observing <span class="emphasis"><em>k</em></span>
|
||||
trials (failures, events, occurrences, or arrivals) before the first success.
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
For this implementation, the set of trials <span class="bold"><strong>includes
|
||||
zero</strong></span> (unlike another definition where the set of trials starts
|
||||
at one, sometimes named <span class="emphasis"><em>shifted</em></span>).
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
The geometric distribution assumes that success_fraction <span class="emphasis"><em>p</em></span>
|
||||
is fixed for all <span class="emphasis"><em>k</em></span> trials.
|
||||
</p>
|
||||
<p>
|
||||
The probability that there are <span class="emphasis"><em>k</em></span> failures before the
|
||||
first success is
|
||||
</p>
|
||||
<p>
|
||||
   Pr(Y=<span class="emphasis"><em>k</em></span>) = (1-<span class="emphasis"><em>p</em></span>)<sup><span class="emphasis"><em>k</em></span></sup><span class="emphasis"><em>p</em></span>
|
||||
</p>
|
||||
<p>
|
||||
For example, when throwing a 6-face dice the success probability <span class="emphasis"><em>p</em></span>
|
||||
= 1/6 = 0.1666 ̇  . Throwing repeatedly until a <span class="emphasis"><em>three</em></span>
|
||||
appears, the probability distribution of the number of times <span class="emphasis"><em>not-a-three</em></span>
|
||||
is thrown is geometric.
|
||||
</p>
|
||||
<p>
|
||||
Geometric distribution has the Probability Density Function PDF:
|
||||
</p>
|
||||
<p>
|
||||
   (1-<span class="emphasis"><em>p</em></span>)<sup><span class="emphasis"><em>k</em></span></sup><span class="emphasis"><em>p</em></span>
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates how the PDF and CDF vary for three examples
|
||||
of the success fraction <span class="emphasis"><em>p</em></span>, (when considering the geometric
|
||||
distribution as a continuous function),
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/geometric_pdf_2.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/geometric_cdf_2.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
and as discrete.
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/geometric_pdf_discrete.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/geometric_cdf_discrete.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.geometric_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.geometric_dist.related_distributions"></a></span><a class="link" href="geometric_dist.html#math_toolkit.dist_ref.dists.geometric_dist.related_distributions">Related
|
||||
Distributions</a>
|
||||
</h5>
|
||||
<p>
|
||||
The geometric distribution is a special case of the <a class="link" href="negative_binomial_dist.html" title="Negative Binomial Distribution">Negative
|
||||
Binomial Distribution</a> with successes parameter <span class="emphasis"><em>r</em></span>
|
||||
= 1, so only one first and only success is required : thus by definition
|
||||
   <code class="computeroutput"><span class="identifier">geometric</span><span class="special">(</span><span class="identifier">p</span><span class="special">)</span> <span class="special">==</span>
|
||||
<span class="identifier">negative_binomial</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">p</span><span class="special">)</span></code>
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">negative_binomial_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">r</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">success_fraction</span><span class="special">);</span>
|
||||
<span class="identifier">negative_binomial</span> <span class="identifier">nb</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">success_fraction</span><span class="special">);</span>
|
||||
<span class="identifier">geometric</span> <span class="identifier">g</span><span class="special">(</span><span class="identifier">success_fraction</span><span class="special">);</span>
|
||||
<span class="identifier">ASSERT</span><span class="special">(</span><span class="identifier">pdf</span><span class="special">(</span><span class="identifier">nb</span><span class="special">,</span> <span class="number">1</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">pdf</span><span class="special">(</span><span class="identifier">g</span><span class="special">,</span> <span class="number">1</span><span class="special">));</span>
|
||||
</pre>
|
||||
<p>
|
||||
This implementation uses real numbers for the computation throughout (because
|
||||
it uses the <span class="bold"><strong>real-valued</strong></span> power and exponential
|
||||
functions). So to obtain a conventional strictly-discrete geometric distribution
|
||||
you must ensure that an integer value is provided for the number of trials
|
||||
(random variable) <span class="emphasis"><em>k</em></span>, and take integer values (floor
|
||||
or ceil functions) from functions that return a number of successes.
|
||||
</p>
|
||||
<div class="caution"><table border="0" summary="Caution">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../../doc/src/images/caution.png"></td>
|
||||
<th align="left">Caution</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
The geometric distribution is a discrete distribution: internally, functions
|
||||
like the <code class="computeroutput"><span class="identifier">cdf</span></code> and <code class="computeroutput"><span class="identifier">pdf</span></code> are treated "as if" they
|
||||
are continuous functions, but in reality the results returned from these
|
||||
functions only have meaning if an integer value is provided for the random
|
||||
variate argument.
|
||||
</p>
|
||||
<p>
|
||||
The quantile function will by default return an integer result that has
|
||||
been <span class="emphasis"><em>rounded outwards</em></span>. That is to say lower quantiles
|
||||
(where the probability is less than 0.5) are rounded downward, and upper
|
||||
quantiles (where the probability is greater than 0.5) are rounded upwards.
|
||||
This behaviour ensures that if an X% quantile is requested, then <span class="emphasis"><em>at
|
||||
least</em></span> the requested coverage will be present in the central
|
||||
region, and <span class="emphasis"><em>no more than</em></span> the requested coverage
|
||||
will be present in the tails.
|
||||
</p>
|
||||
<p>
|
||||
This behaviour can be changed so that the quantile functions are rounded
|
||||
differently, or even return a real-valued result using <a class="link" href="../../pol_overview.html" title="Policy Overview">Policies</a>.
|
||||
It is strongly recommended that you read the tutorial <a class="link" href="../../pol_tutorial/understand_dis_quant.html" title="Understanding Quantiles of Discrete Distributions">Understanding
|
||||
Quantiles of Discrete Distributions</a> before using the quantile
|
||||
function on the geometric distribution. The <a class="link" href="../../pol_ref/discrete_quant_ref.html" title="Discrete Quantile Policies">reference
|
||||
docs</a> describe how to change the rounding policy for these distributions.
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.geometric_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.geometric_dist.member_functions"></a></span><a class="link" href="geometric_dist.html#math_toolkit.dist_ref.dists.geometric_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.geometric_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.geometric_dist.constructor"></a></span><a class="link" href="geometric_dist.html#math_toolkit.dist_ref.dists.geometric_dist.constructor">Constructor</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="identifier">geometric_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructor: <span class="emphasis"><em>p</em></span> or success_fraction is the probability
|
||||
of success of a single trial.
|
||||
</p>
|
||||
<p>
|
||||
Requires: <code class="computeroutput"><span class="number">0</span> <span class="special"><=</span>
|
||||
<span class="identifier">p</span> <span class="special"><=</span>
|
||||
<span class="number">1</span></code>.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.geometric_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.geometric_dist.accessors"></a></span><a class="link" href="geometric_dist.html#math_toolkit.dist_ref.dists.geometric_dist.accessors">Accessors</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">success_fraction</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> <span class="comment">// successes / trials (0 <= p <= 1)</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the success_fraction parameter <span class="emphasis"><em>p</em></span> from which
|
||||
this distribution was constructed.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> <span class="comment">// required successes always one,</span>
|
||||
<span class="comment">// included for compatibility with negative binomial distribution</span>
|
||||
<span class="comment">// with successes r == 1.</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns unity.
|
||||
</p>
|
||||
<p>
|
||||
The following functions are equivalent to those provided for the negative
|
||||
binomial, with successes = 1, but are provided here for completeness.
|
||||
</p>
|
||||
<p>
|
||||
The best method of calculation for the following functions is disputed:
|
||||
see <a class="link" href="binomial_dist.html" title="Binomial Distribution">Binomial
|
||||
Distribution</a> and <a class="link" href="negative_binomial_dist.html" title="Negative Binomial Distribution">Negative
|
||||
Binomial Distribution</a> for more discussion.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.geometric_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.geometric_dist.lower_bound_on_success_fraction_"></a></span><a class="link" href="geometric_dist.html#math_toolkit.dist_ref.dists.geometric_dist.lower_bound_on_success_fraction_">Lower
|
||||
Bound on success_fraction Parameter <span class="emphasis"><em>p</em></span></a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_lower_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">failures</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">)</span> <span class="comment">// (0 <= alpha <= 1), 0.05 equivalent to 95% confidence.</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns a <span class="bold"><strong>lower bound</strong></span> on the success fraction:
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">failures</span></dt>
|
||||
<dd><p>
|
||||
The total number of failures before the 1st success.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The largest acceptable probability that the true value of the success
|
||||
fraction is <span class="bold"><strong>less than</strong></span> the value
|
||||
returned.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
For example, if you observe <span class="emphasis"><em>k</em></span> failures from <span class="emphasis"><em>n</em></span>
|
||||
trials the best estimate for the success fraction is simply 1/<span class="emphasis"><em>n</em></span>,
|
||||
but if you want to be 95% sure that the true value is <span class="bold"><strong>greater
|
||||
than</strong></span> some value, <span class="emphasis"><em>p<sub>min</sub></em></span>, then:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">p</span><sub>min</sub> <span class="special">=</span> <span class="identifier">geometric_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span>
|
||||
<span class="identifier">find_lower_bound_on_p</span><span class="special">(</span><span class="identifier">failures</span><span class="special">,</span> <span class="number">0.05</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
<a class="link" href="../../stat_tut/weg/neg_binom_eg/neg_binom_conf.html" title="Calculating Confidence Limits on the Frequency of Occurrence for the Negative Binomial Distribution">See
|
||||
negative_binomial confidence interval example.</a>
|
||||
</p>
|
||||
<p>
|
||||
This function uses the Clopper-Pearson method of computing the lower bound
|
||||
on the success fraction, whilst many texts refer to this method as giving
|
||||
an "exact" result in practice it produces an interval that guarantees
|
||||
<span class="emphasis"><em>at least</em></span> the coverage required, and may produce pessimistic
|
||||
estimates for some combinations of <span class="emphasis"><em>failures</em></span> and <span class="emphasis"><em>successes</em></span>.
|
||||
See:
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://www.ucs.louisiana.edu/~kxk4695/Discrete_new.pdf" target="_top">Yong
|
||||
Cai and K. Krishnamoorthy, A Simple Improved Inferential Method for Some
|
||||
Discrete Distributions. Computational statistics and data analysis, 2005,
|
||||
vol. 48, no3, 605-621</a>.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.geometric_dist.h5"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.geometric_dist.upper_bound_on_success_fraction_"></a></span><a class="link" href="geometric_dist.html#math_toolkit.dist_ref.dists.geometric_dist.upper_bound_on_success_fraction_">Upper
|
||||
Bound on success_fraction Parameter p</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_upper_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">trials</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">);</span> <span class="comment">// (0 <= alpha <= 1), 0.05 equivalent to 95% confidence.</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns an <span class="bold"><strong>upper bound</strong></span> on the success
|
||||
fraction:
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">trials</span></dt>
|
||||
<dd><p>
|
||||
The total number of trials conducted.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The largest acceptable probability that the true value of the success
|
||||
fraction is <span class="bold"><strong>greater than</strong></span> the value
|
||||
returned.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
For example, if you observe <span class="emphasis"><em>k</em></span> successes from <span class="emphasis"><em>n</em></span>
|
||||
trials the best estimate for the success fraction is simply <span class="emphasis"><em>k/n</em></span>,
|
||||
but if you want to be 95% sure that the true value is <span class="bold"><strong>less
|
||||
than</strong></span> some value, <span class="emphasis"><em>p<sub>max</sub></em></span>, then:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">p</span><sub>max</sub> <span class="special">=</span> <span class="identifier">geometric_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">find_upper_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">k</span><span class="special">,</span> <span class="number">0.05</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
<a class="link" href="../../stat_tut/weg/neg_binom_eg/neg_binom_conf.html" title="Calculating Confidence Limits on the Frequency of Occurrence for the Negative Binomial Distribution">See
|
||||
negative binomial confidence interval example.</a>
|
||||
</p>
|
||||
<p>
|
||||
This function uses the Clopper-Pearson method of computing the lower bound
|
||||
on the success fraction, whilst many texts refer to this method as giving
|
||||
an "exact" result in practice it produces an interval that guarantees
|
||||
<span class="emphasis"><em>at least</em></span> the coverage required, and may produce pessimistic
|
||||
estimates for some combinations of <span class="emphasis"><em>failures</em></span> and <span class="emphasis"><em>successes</em></span>.
|
||||
See:
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://www.ucs.louisiana.edu/~kxk4695/Discrete_new.pdf" target="_top">Yong
|
||||
Cai and K. Krishnamoorthy, A Simple Improved Inferential Method for Some
|
||||
Discrete Distributions. Computational statistics and data analysis, 2005,
|
||||
vol. 48, no3, 605-621</a>.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.geometric_dist.h6"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.geometric_dist.estimating_number_of_trials_to_e"></a></span><a class="link" href="geometric_dist.html#math_toolkit.dist_ref.dists.geometric_dist.estimating_number_of_trials_to_e">Estimating
|
||||
Number of Trials to Ensure at Least a Certain Number of Failures</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_minimum_number_of_trials</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">k</span><span class="special">,</span> <span class="comment">// number of failures.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// success fraction.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">);</span> <span class="comment">// probability threshold (0.05 equivalent to 95%).</span>
|
||||
</pre>
|
||||
<p>
|
||||
This functions estimates the number of trials required to achieve a certain
|
||||
probability that <span class="bold"><strong>more than <span class="emphasis"><em>k</em></span>
|
||||
failures will be observed</strong></span>.
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">k</span></dt>
|
||||
<dd><p>
|
||||
The target number of failures to be observed.
|
||||
</p></dd>
|
||||
<dt><span class="term">p</span></dt>
|
||||
<dd><p>
|
||||
The probability of <span class="emphasis"><em>success</em></span> for each trial.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The maximum acceptable <span class="emphasis"><em>risk</em></span> that only <span class="emphasis"><em>k</em></span>
|
||||
failures or fewer will be observed.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">geometric_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">find_minimum_number_of_trials</span><span class="special">(</span><span class="number">10</span><span class="special">,</span> <span class="number">0.5</span><span class="special">,</span> <span class="number">0.05</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the smallest number of trials we must conduct to be 95% (1-0.05)
|
||||
sure of seeing 10 failures that occur with frequency one half.
|
||||
</p>
|
||||
<p>
|
||||
<a class="link" href="../../stat_tut/weg/neg_binom_eg/neg_binom_size_eg.html" title="Estimating Sample Sizes for the Negative Binomial.">Worked
|
||||
Example.</a>
|
||||
</p>
|
||||
<p>
|
||||
This function uses numeric inversion of the geometric distribution to obtain
|
||||
the result: another interpretation of the result is that it finds the number
|
||||
of trials (failures) that will lead to an <span class="emphasis"><em>alpha</em></span> probability
|
||||
of observing <span class="emphasis"><em>k</em></span> failures or fewer.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.geometric_dist.h7"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.geometric_dist.estimating_number_of_trials_to_0"></a></span><a class="link" href="geometric_dist.html#math_toolkit.dist_ref.dists.geometric_dist.estimating_number_of_trials_to_0">Estimating
|
||||
Number of Trials to Ensure a Maximum Number of Failures or Less</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_maximum_number_of_trials</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">k</span><span class="special">,</span> <span class="comment">// number of failures.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// success fraction.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">);</span> <span class="comment">// probability threshold (0.05 equivalent to 95%).</span>
|
||||
</pre>
|
||||
<p>
|
||||
This functions estimates the maximum number of trials we can conduct and
|
||||
achieve a certain probability that <span class="bold"><strong>k failures or
|
||||
fewer will be observed</strong></span>.
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">k</span></dt>
|
||||
<dd><p>
|
||||
The maximum number of failures to be observed.
|
||||
</p></dd>
|
||||
<dt><span class="term">p</span></dt>
|
||||
<dd><p>
|
||||
The probability of <span class="emphasis"><em>success</em></span> for each trial.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The maximum acceptable <span class="emphasis"><em>risk</em></span> that more than
|
||||
<span class="emphasis"><em>k</em></span> failures will be observed.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">geometric_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">find_maximum_number_of_trials</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">1.0</span><span class="special">-</span><span class="number">1.0</span><span class="special">/</span><span class="number">1000000</span><span class="special">,</span> <span class="number">0.05</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the largest number of trials we can conduct and still be 95% sure
|
||||
of seeing no failures that occur with frequency one in one million.
|
||||
</p>
|
||||
<p>
|
||||
This function uses numeric inversion of the geometric distribution to obtain
|
||||
the result: another interpretation of the result, is that it finds the
|
||||
number of trials that will lead to an <span class="emphasis"><em>alpha</em></span> probability
|
||||
of observing more than k failures.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.geometric_dist.h8"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.geometric_dist.non_member_accessors"></a></span><a class="link" href="geometric_dist.html#math_toolkit.dist_ref.dists.geometric_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
However it's worth taking a moment to define what these actually mean in
|
||||
the context of this distribution:
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="math_toolkit.dist_ref.dists.geometric_dist.meaning_of_the_non_member_access"></a><p class="title"><b>Table 5.2. Meaning of the non-member accessors.</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Meaning of the non-member accessors.">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Meaning
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density
|
||||
Function</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The probability of obtaining <span class="bold"><strong>exactly k
|
||||
failures</strong></span> from <span class="emphasis"><em>k</em></span> trials with success
|
||||
fraction p. For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">pdf</span><span class="special">(</span><span class="identifier">geometric</span><span class="special">(</span><span class="identifier">p</span><span class="special">),</span> <span class="identifier">k</span><span class="special">)</span></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution
|
||||
Function</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The probability of obtaining <span class="bold"><strong>k failures
|
||||
or fewer</strong></span> from <span class="emphasis"><em>k</em></span> trials with success
|
||||
fraction p and success on the last trial. For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">geometric</span><span class="special">(</span><span class="identifier">p</span><span class="special">),</span> <span class="identifier">k</span><span class="special">)</span></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.ccdf">Complement of
|
||||
the Cumulative Distribution Function</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The probability of obtaining <span class="bold"><strong>more than
|
||||
k failures</strong></span> from <span class="emphasis"><em>k</em></span> trials with
|
||||
success fraction p and success on the last trial. For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">geometric</span><span class="special">(</span><span class="identifier">p</span><span class="special">),</span> <span class="identifier">k</span><span class="special">))</span></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The <span class="bold"><strong>greatest</strong></span> number of failures
|
||||
<span class="emphasis"><em>k</em></span> expected to be observed from <span class="emphasis"><em>k</em></span>
|
||||
trials with success fraction <span class="emphasis"><em>p</em></span>, at probability
|
||||
<span class="emphasis"><em>P</em></span>. Note that the value returned is a real-number,
|
||||
and not an integer. Depending on the use case you may want to
|
||||
take either the floor or ceiling of the real result. For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">geometric</span><span class="special">(</span><span class="identifier">p</span><span class="special">),</span> <span class="identifier">P</span><span class="special">)</span></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.quantile_c">Quantile
|
||||
from the complement of the probability</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The <span class="bold"><strong>smallest</strong></span> number of failures
|
||||
<span class="emphasis"><em>k</em></span> expected to be observed from <span class="emphasis"><em>k</em></span>
|
||||
trials with success fraction <span class="emphasis"><em>p</em></span>, at probability
|
||||
<span class="emphasis"><em>P</em></span>. Note that the value returned is a real-number,
|
||||
and not an integer. Depending on the use case you may want to
|
||||
take either the floor or ceiling of the real result. For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">geometric</span><span class="special">(</span><span class="identifier">p</span><span class="special">),</span> <span class="identifier">P</span><span class="special">))</span></pre>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break"><h5>
|
||||
<a name="math_toolkit.dist_ref.dists.geometric_dist.h9"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.geometric_dist.accuracy"></a></span><a class="link" href="geometric_dist.html#math_toolkit.dist_ref.dists.geometric_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
This distribution is implemented using the pow and exp functions, so most
|
||||
results are accurate within a few epsilon for the RealType. For extreme
|
||||
values of <code class="computeroutput"><span class="keyword">double</span></code> <span class="emphasis"><em>p</em></span>,
|
||||
for example 0.9999999999, accuracy can fall significantly, for example
|
||||
to 10 decimal digits (from 16).
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.geometric_dist.h10"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.geometric_dist.implementation"></a></span><a class="link" href="geometric_dist.html#math_toolkit.dist_ref.dists.geometric_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table, <span class="emphasis"><em>p</em></span> is the probability that
|
||||
any one trial will be successful (the success fraction), <span class="emphasis"><em>k</em></span>
|
||||
is the number of failures, <span class="emphasis"><em>p</em></span> is the probability and
|
||||
<span class="emphasis"><em>q = 1-p</em></span>, <span class="emphasis"><em>x</em></span> is the given probability
|
||||
to estimate the expected number of failures using the quantile.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
pdf = p * pow(q, k)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
cdf = 1 - q<sup>k=1</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
exp(log1p(-p) * (k+1))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
k = log1p(-x) / log1p(-p) -1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
k = log(x) / log1p(-p) -1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(1-p)/p
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(1-p)/p²
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
0
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(2-p)/√q
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
9+p²/q
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
6 +p²/q
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
parameter estimation member functions
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
See <a class="link" href="negative_binomial_dist.html" title="Negative Binomial Distribution">Negative
|
||||
Binomial Distribution</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">find_lower_bound_on_p</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
See <a class="link" href="negative_binomial_dist.html" title="Negative Binomial Distribution">Negative
|
||||
Binomial Distribution</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">find_upper_bound_on_p</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
See <a class="link" href="negative_binomial_dist.html" title="Negative Binomial Distribution">Negative
|
||||
Binomial Distribution</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">find_minimum_number_of_trials</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
See <a class="link" href="negative_binomial_dist.html" title="Negative Binomial Distribution">Negative
|
||||
Binomial Distribution</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">find_maximum_number_of_trials</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
See <a class="link" href="negative_binomial_dist.html" title="Negative Binomial Distribution">Negative
|
||||
Binomial Distribution</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="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="hyperexponential_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,339 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Hypergeometric Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="hyperexponential_dist.html" title="Hyperexponential Distribution">
|
||||
<link rel="next" href="inverse_chi_squared_dist.html" title="Inverse Chi Squared Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="hyperexponential_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="inverse_chi_squared_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.hypergeometric_dist"></a><a class="link" href="hypergeometric_dist.html" title="Hypergeometric Distribution">Hypergeometric
|
||||
Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">hypergeometric</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">hypergeometric_distribution</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <span class="identifier">Policy</span><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">hypergeometric_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
<span class="comment">// Construct:</span>
|
||||
<span class="identifier">hypergeometric_distribution</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">r</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">N</span><span class="special">);</span>
|
||||
<span class="comment">// Accessors:</span>
|
||||
<span class="keyword">unsigned</span> <span class="identifier">total</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="keyword">unsigned</span> <span class="identifier">defective</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="keyword">unsigned</span> <span class="identifier">sample_count</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">hypergeometric_distribution</span><span class="special"><></span> <span class="identifier">hypergeometric</span><span class="special">;</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The hypergeometric distribution describes the number of "events"
|
||||
<span class="emphasis"><em>k</em></span> from a sample <span class="emphasis"><em>n</em></span> drawn from
|
||||
a total population <span class="emphasis"><em>N</em></span> <span class="emphasis"><em>without replacement</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Imagine we have a sample of <span class="emphasis"><em>N</em></span> objects of which <span class="emphasis"><em>r</em></span>
|
||||
are "defective" and N-r are "not defective" (the terms
|
||||
"success/failure" or "red/blue" are also used). If
|
||||
we sample <span class="emphasis"><em>n</em></span> items <span class="emphasis"><em>without replacement</em></span>
|
||||
then what is the probability that exactly <span class="emphasis"><em>k</em></span> items
|
||||
in the sample are defective? The answer is given by the pdf of the hypergeometric
|
||||
distribution <code class="computeroutput"><span class="identifier">f</span><span class="special">(</span><span class="identifier">k</span><span class="special">;</span> <span class="identifier">r</span><span class="special">,</span> <span class="identifier">n</span><span class="special">,</span>
|
||||
<span class="identifier">N</span><span class="special">)</span></code>,
|
||||
whilst the probability of <span class="emphasis"><em>k</em></span> defectives or fewer is
|
||||
given by F(k; r, n, N), where F(k) is the CDF of the hypergeometric distribution.
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
Unlike almost all of the other distributions in this library, the hypergeometric
|
||||
distribution is strictly discrete: it can not be extended to real valued
|
||||
arguments of its parameters or random variable.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
The following graph shows how the distribution changes as the proportion
|
||||
of "defective" items changes, while keeping the population and
|
||||
sample sizes constant:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/hypergeometric_pdf_1.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
Note that since the distribution is symmetrical in parameters <span class="emphasis"><em>n</em></span>
|
||||
and <span class="emphasis"><em>r</em></span>, if we change the sample size and keep the population
|
||||
and proportion "defective" the same then we obtain basically
|
||||
the same graphs:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/hypergeometric_pdf_2.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.hypergeometric_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.hypergeometric_dist.member_functions"></a></span><a class="link" href="hypergeometric_dist.html#math_toolkit.dist_ref.dists.hypergeometric_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">hypergeometric_distribution</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">r</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">N</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a hypergeometric distribution with a population of <span class="emphasis"><em>N</em></span>
|
||||
objects, of which <span class="emphasis"><em>r</em></span> are defective, and from which
|
||||
<span class="emphasis"><em>n</em></span> are sampled.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">unsigned</span> <span class="identifier">total</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the total number of objects <span class="emphasis"><em>N</em></span>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">unsigned</span> <span class="identifier">defective</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the number of objects <span class="emphasis"><em>r</em></span> in population <span class="emphasis"><em>N</em></span>
|
||||
which are defective.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">unsigned</span> <span class="identifier">sample_count</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the number of objects <span class="emphasis"><em>n</em></span> which are sampled
|
||||
from the population <span class="emphasis"><em>N</em></span>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.hypergeometric_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.hypergeometric_dist.non_member_accessors"></a></span><a class="link" href="hypergeometric_dist.html#math_toolkit.dist_ref.dists.hypergeometric_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is the unsigned integers in the range
|
||||
[max(0, n + r - N), min(n, r)]. A <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
is raised if the random variable is outside this range, or is not an integral
|
||||
value.
|
||||
</p>
|
||||
<div class="caution"><table border="0" summary="Caution">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../../doc/src/images/caution.png"></td>
|
||||
<th align="left">Caution</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
The quantile function will by default return an integer result that has
|
||||
been <span class="emphasis"><em>rounded outwards</em></span>. That is to say lower quantiles
|
||||
(where the probability is less than 0.5) are rounded downward, and upper
|
||||
quantiles (where the probability is greater than 0.5) are rounded upwards.
|
||||
This behaviour ensures that if an X% quantile is requested, then <span class="emphasis"><em>at
|
||||
least</em></span> the requested coverage will be present in the central
|
||||
region, and <span class="emphasis"><em>no more than</em></span> the requested coverage
|
||||
will be present in the tails.
|
||||
</p>
|
||||
<p>
|
||||
This behaviour can be changed so that the quantile functions are rounded
|
||||
differently using <a class="link" href="../../pol_overview.html" title="Policy Overview">Policies</a>.
|
||||
It is strongly recommended that you read the tutorial <a class="link" href="../../pol_tutorial/understand_dis_quant.html" title="Understanding Quantiles of Discrete Distributions">Understanding
|
||||
Quantiles of Discrete Distributions</a> before using the quantile
|
||||
function on the Hypergeometric distribution. The <a class="link" href="../../pol_ref/discrete_quant_ref.html" title="Discrete Quantile Policies">reference
|
||||
docs</a> describe how to change the rounding policy for these distributions.
|
||||
</p>
|
||||
<p>
|
||||
However, note that the implementation method of the quantile function
|
||||
always returns an integral value, therefore attempting to use a <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> that requires (or produces) a real valued
|
||||
result will result in a compile time error.
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.hypergeometric_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.hypergeometric_dist.accuracy"></a></span><a class="link" href="hypergeometric_dist.html#math_toolkit.dist_ref.dists.hypergeometric_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
For small N such that <code class="computeroutput"><span class="identifier">N</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">max_factorial</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">value</span></code>
|
||||
then table based lookup of the results gives an accuracy to a few epsilon.
|
||||
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">max_factorial</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">value</span></code> is 170 at double or long double
|
||||
precision.
|
||||
</p>
|
||||
<p>
|
||||
For larger N such that <code class="computeroutput"><span class="identifier">N</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">prime</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">max_prime</span><span class="special">)</span></code> then only basic arithmetic is required
|
||||
for the calculation and the accuracy is typically < 20 epsilon. This
|
||||
takes care of N up to 104729.
|
||||
</p>
|
||||
<p>
|
||||
For <code class="computeroutput"><span class="identifier">N</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">prime</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">max_prime</span><span class="special">)</span></code>
|
||||
then accuracy quickly degrades, with 5 or 6 decimal digits being lost for
|
||||
N = 110000.
|
||||
</p>
|
||||
<p>
|
||||
In general for very large N, the user should expect to lose log<sub>10</sub>N decimal
|
||||
digits of precision during the calculation, with the results becoming meaningless
|
||||
for N >= 10<sup>15</sup>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.hypergeometric_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.hypergeometric_dist.testing"></a></span><a class="link" href="hypergeometric_dist.html#math_toolkit.dist_ref.dists.hypergeometric_dist.testing">Testing</a>
|
||||
</h5>
|
||||
<p>
|
||||
There are three sets of tests: our implementation is tested against a table
|
||||
of values produced by Mathematica's implementation of this distribution.
|
||||
We also sanity check our implementation against some spot values computed
|
||||
using the online calculator here <a href="http://stattrek.com/Tables/Hypergeometric.aspx" target="_top">http://stattrek.com/Tables/Hypergeometric.aspx</a>.
|
||||
Finally we test accuracy against some high precision test data using this
|
||||
implementation and NTL::RR.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.hypergeometric_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.hypergeometric_dist.implementation"></a></span><a class="link" href="hypergeometric_dist.html#math_toolkit.dist_ref.dists.hypergeometric_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
The PDF can be calculated directly using the formula:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/hypergeometric1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
However, this can only be used directly when the largest of the factorials
|
||||
is guaranteed not to overflow the floating point representation used. This
|
||||
formula is used directly when <code class="computeroutput"><span class="identifier">N</span>
|
||||
<span class="special"><</span> <span class="identifier">max_factorial</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">value</span></code>
|
||||
in which case table lookup of the factorials gives a rapid and accurate
|
||||
implementation method.
|
||||
</p>
|
||||
<p>
|
||||
For larger <span class="emphasis"><em>N</em></span> the method described in "An Accurate
|
||||
Computation of the Hypergeometric Distribution Function", Trong Wu,
|
||||
ACM Transactions on Mathematical Software, Vol. 19, No. 1, March 1993,
|
||||
Pages 33-43 is used. The method relies on the fact that there is an easy
|
||||
method for factorising a factorial into the product of prime numbers:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/hypergeometric2.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
Where p<sub>i</sub> is the i'th prime number, and e<sub>i</sub> is a small positive integer or
|
||||
zero, which can be calculated via:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/hypergeometric3.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
Further we can combine the factorials in the expression for the PDF to
|
||||
yield the PDF directly as the product of prime numbers:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/hypergeometric4.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
With this time the exponents e<sub>i</sub> being either positive, negative or zero.
|
||||
Indeed such a degree of cancellation occurs in the calculation of the e<sub>i</sub> that
|
||||
many are zero, and typically most have a magnitude or no more than 1 or
|
||||
2.
|
||||
</p>
|
||||
<p>
|
||||
Calculation of the product of the primes requires some care to prevent
|
||||
numerical overflow, we use a novel recursive method which splits the calculation
|
||||
into a series of sub-products, with a new sub-product started each time
|
||||
the next multiplication would cause either overflow or underflow. The sub-products
|
||||
are stored in a linked list on the program stack, and combined in an order
|
||||
that will guarantee no overflow or unnecessary-underflow once the last
|
||||
sub-product has been calculated.
|
||||
</p>
|
||||
<p>
|
||||
This method can be used as long as N is smaller than the largest prime
|
||||
number we have stored in our table of primes (currently 104729). The method
|
||||
is relatively slow (calculating the exponents requires the most time),
|
||||
but requires only a small number of arithmetic operations to calculate
|
||||
the result (indeed there is no shorter method involving only basic arithmetic
|
||||
once the exponents have been found), the method is therefore much more
|
||||
accurate than the alternatives.
|
||||
</p>
|
||||
<p>
|
||||
For much larger N, we can calculate the PDF from the factorials using either
|
||||
lgamma, or by directly combining lanczos approximations to avoid calculating
|
||||
via logarithms. We use the latter method, as it is usually 1 or 2 decimal
|
||||
digits more accurate than computing via logarithms with lgamma. However,
|
||||
in this area where N > 104729, the user should expect to lose around
|
||||
log<sub>10</sub>N decimal digits during the calculation in the worst case.
|
||||
</p>
|
||||
<p>
|
||||
The CDF and its complement is calculated by directly summing the PDF's.
|
||||
We start by deciding whether the CDF, or its complement, is likely to be
|
||||
the smaller of the two and then calculate the PDF at <span class="emphasis"><em>k</em></span>
|
||||
(or <span class="emphasis"><em>k+1</em></span> if we're calculating the complement) and calculate
|
||||
successive PDF values via the recurrence relations:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/hypergeometric5.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
Until we either reach the end of the distributions domain, or the next
|
||||
PDF value to be summed would be too small to affect the result.
|
||||
</p>
|
||||
<p>
|
||||
The quantile is calculated in a similar manner to the CDF: we first guess
|
||||
which end of the distribution we're nearer to, and then sum PDFs starting
|
||||
from the end of the distribution this time, until we have some value <span class="emphasis"><em>k</em></span>
|
||||
that gives the required CDF.
|
||||
</p>
|
||||
<p>
|
||||
The median is simply the quantile at 0.5, and the remaining properties
|
||||
are calculated via:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/hypergeometric6.svg"></span>
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="hyperexponential_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="inverse_chi_squared_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,471 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Inverse Chi Squared Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="hypergeometric_dist.html" title="Hypergeometric Distribution">
|
||||
<link rel="next" href="inverse_gamma_dist.html" title="Inverse Gamma Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="hypergeometric_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="inverse_gamma_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_chi_squared_dist"></a><a class="link" href="inverse_chi_squared_dist.html" title="Inverse Chi Squared Distribution">Inverse
|
||||
Chi Squared Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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_chi_squared</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">inverse_chi_squared_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">inverse_chi_squared_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="comment">// Not explicitly scaled, default 1/df.</span>
|
||||
<span class="identifier">inverse_chi_squared_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">df</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="identifier">df</span><span class="special">);</span> <span class="comment">// Scaled.</span>
|
||||
|
||||
<span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// Default 1.</span>
|
||||
<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 [xi] (variance), default 1/degrees_of_freedom.</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespace boost // namespace math</span>
|
||||
</pre>
|
||||
<p>
|
||||
The inverse chi squared distribution is a continuous probability distribution
|
||||
of the <span class="bold"><strong>reciprocal</strong></span> of a variable distributed
|
||||
according to the chi squared distribution.
|
||||
</p>
|
||||
<p>
|
||||
The sources below give confusingly different formulae using different symbols
|
||||
for the distribution pdf, but they are all the same, or related by a change
|
||||
of variable, or choice of scale.
|
||||
</p>
|
||||
<p>
|
||||
Two constructors are available to implement both the scaled and (implicitly)
|
||||
unscaled versions.
|
||||
</p>
|
||||
<p>
|
||||
The main version has an explicit scale parameter which implements the
|
||||
<a href="http://en.wikipedia.org/wiki/Scaled-inverse-chi-square_distribution" target="_top">scaled
|
||||
inverse chi_squared distribution</a>.
|
||||
</p>
|
||||
<p>
|
||||
A second version has an implicit scale = 1/degrees of freedom and gives
|
||||
the 1st definition in the <a href="http://en.wikipedia.org/wiki/Inverse-chi-square_distribution" target="_top">Wikipedia
|
||||
inverse chi_squared distribution</a>. The 2nd Wikipedia inverse chi_squared
|
||||
distribution definition can be implemented by explicitly specifying a scale
|
||||
= 1.
|
||||
</p>
|
||||
<p>
|
||||
Both definitions are also available in Wolfram Mathematica and in <a href="http://www.r-project.org/" target="_top">The R Project for Statistical Computing</a>
|
||||
(geoR) with default scale = 1/degrees of freedom.
|
||||
</p>
|
||||
<p>
|
||||
See
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
Inverse chi_squared distribution <a href="http://en.wikipedia.org/wiki/Inverse-chi-square_distribution" target="_top">http://en.wikipedia.org/wiki/Inverse-chi-square_distribution</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Scaled inverse chi_squared distribution<a href="http://en.wikipedia.org/wiki/Scaled-inverse-chi-square_distribution" target="_top">http://en.wikipedia.org/wiki/Scaled-inverse-chi-square_distribution</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
R inverse chi_squared distribution functions <a href="http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/geoR/html/InvChisquare.html" target="_top">R
|
||||
</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Inverse chi_squared distribution functions <a href="http://mathworld.wolfram.com/InverseChi-SquaredDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Inverse Chi-Squared Distribution." From MathWorld--A
|
||||
Wolfram Web Resource.</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Inverse chi_squared distribution reference <a href="http://reference.wolfram.com/mathematica/ref/InverseChiSquareDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Inverse Chi-Squared Distribution reference." From
|
||||
Wolfram Mathematica.</a>
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
The inverse_chi_squared distribution is used in <a href="http://en.wikipedia.org/wiki/Bayesian_statistics" target="_top">Bayesian
|
||||
statistics</a>: the scaled inverse chi-square is conjugate prior for
|
||||
the normal distribution with known mean, model parameter σ² (variance).
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://en.wikipedia.org/wiki/Conjugate_prior" target="_top">conjugate
|
||||
priors including a table of distributions and their priors.</a>
|
||||
</p>
|
||||
<p>
|
||||
See also <a class="link" href="inverse_gamma_dist.html" title="Inverse Gamma Distribution">Inverse
|
||||
Gamma Distribution</a> and <a class="link" href="chi_squared_dist.html" title="Chi Squared Distribution">Chi
|
||||
Squared Distribution</a>.
|
||||
</p>
|
||||
<p>
|
||||
The inverse_chi_squared distribution is a special case of a inverse_gamma
|
||||
distribution with ν (degrees_of_freedom) shape (α) and scale (β) where
|
||||
</p>
|
||||
<p>
|
||||
   α= ν /2 and β = ½.
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
This distribution <span class="bold"><strong>does</strong></span> provide the typedef:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">inverse_chi_squared_distribution</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">inverse_chi_squared</span><span class="special">;</span></pre>
|
||||
<p>
|
||||
If you want a <code class="computeroutput"><span class="keyword">double</span></code> precision
|
||||
inverse_chi_squared distribution you can use
|
||||
</p>
|
||||
<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_chi_squared_distribution</span><span class="special"><></span></pre>
|
||||
<p>
|
||||
or you can write <code class="computeroutput"><span class="identifier">inverse_chi_squared</span>
|
||||
<span class="identifier">my_invchisqr</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">);</span></code>
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
For degrees of freedom parameter ν, the (<span class="bold"><strong>unscaled</strong></span>)
|
||||
inverse chi_squared distribution is defined by the probability density
|
||||
function (PDF):
|
||||
</p>
|
||||
<p>
|
||||
   f(x;ν) = 2<sup>-ν/2</sup> x<sup>-ν/2-1</sup> e<sup>-1/2x</sup> / Γ(ν/2)
|
||||
</p>
|
||||
<p>
|
||||
and Cumulative Density Function (CDF)
|
||||
</p>
|
||||
<p>
|
||||
   F(x;ν) = Γ(ν/2, 1/2x) / Γ(ν/2)
|
||||
</p>
|
||||
<p>
|
||||
For degrees of freedom parameter ν and scale parameter ξ, the <span class="bold"><strong>scaled</strong></span>
|
||||
inverse chi_squared distribution is defined by the probability density
|
||||
function (PDF):
|
||||
</p>
|
||||
<p>
|
||||
   f(x;ν, ξ) = (ξν/2)<sup>ν/2</sup> e<sup>-νξ/2x</sup> x<sup>-1-ν/2</sup> / Γ(ν/2)
|
||||
</p>
|
||||
<p>
|
||||
and Cumulative Density Function (CDF)
|
||||
</p>
|
||||
<p>
|
||||
   F(x;ν, ξ) = Γ(ν/2, νξ/2x) / Γ(ν/2)
|
||||
</p>
|
||||
<p>
|
||||
The following graphs illustrate how the PDF and CDF of the inverse chi_squared
|
||||
distribution varies for a few values of parameters ν and ξ:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/inverse_chi_squared_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/inverse_chi_squared_cdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_chi_squared_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_chi_squared_dist.member_functions"></a></span><a class="link" href="inverse_chi_squared_dist.html#math_toolkit.dist_ref.dists.inverse_chi_squared_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">inverse_chi_squared_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="comment">// Implicitly scaled 1/df.</span>
|
||||
<span class="identifier">inverse_chi_squared_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="comment">// Explicitly scaled.</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs an inverse chi_squared distribution with ν degrees of freedom
|
||||
<span class="emphasis"><em>df</em></span>, and scale <span class="emphasis"><em>scale</em></span> with default
|
||||
value 1/df.
|
||||
</p>
|
||||
<p>
|
||||
Requires that the degrees of freedom ν parameter is greater than zero, otherwise
|
||||
calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the degrees_of_freedom ν parameter of this distribution.
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the scale ξ parameter of this distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_chi_squared_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_chi_squared_dist.non_member_accessors"></a></span><a class="link" href="inverse_chi_squared_dist.html#math_toolkit.dist_ref.dists.inverse_chi_squared_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variate is [0,+∞].
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
Unlike some definitions, this implementation supports a random variate
|
||||
equal to zero as a special case, returning zero for both pdf and cdf.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_chi_squared_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_chi_squared_dist.accuracy"></a></span><a class="link" href="inverse_chi_squared_dist.html#math_toolkit.dist_ref.dists.inverse_chi_squared_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The inverse gamma distribution is implemented in terms of the incomplete
|
||||
gamma functions like the <a class="link" href="inverse_gamma_dist.html" title="Inverse Gamma Distribution">Inverse
|
||||
Gamma Distribution</a> that use <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_p</a>
|
||||
and <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_q</a> and their
|
||||
inverses <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_p_inv</a>
|
||||
and <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_q_inv</a>:
|
||||
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 64-bit double. unless
|
||||
iteration is involved, as for the estimation of degrees of freedom.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_chi_squared_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_chi_squared_dist.implementation"></a></span><a class="link" href="inverse_chi_squared_dist.html#math_toolkit.dist_ref.dists.inverse_chi_squared_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table ν is the degrees of freedom parameter and ξ is the scale
|
||||
parameter of the distribution, <span class="emphasis"><em>x</em></span> is the random variate,
|
||||
<span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q = 1-p</em></span>
|
||||
its complement. Parameters α for shape and β for scale are used for the inverse
|
||||
gamma function: α = ν/2 and β = ν * ξ/2.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = <a class="link" href="../../sf_gamma/gamma_derivatives.html" title="Derivative of the Incomplete Gamma Function">gamma_p_derivative</a>(α,
|
||||
β/ x, β) / x * x
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: p = <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_q</a>(α,
|
||||
β / x)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_p</a>(α,
|
||||
β / x)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = β  / <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_q_inv</a>(α,
|
||||
p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = α  / <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_p_inv</a>(α,
|
||||
q)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
ν * ξ / (ν + 2)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
median
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
no closed form analytic equation is known, but is evaluated as
|
||||
quantile(0.5)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
νξ / (ν - 2) for ν > 2, else a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
2 ν² ξ² / ((ν -2)² (ν -4)) for ν >4, else a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
4 √2 √(ν-4) /(ν-6) for ν >6, else a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis_excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12 * (5ν - 22) / ((ν - 6) * (ν - 8)) for ν >8, else a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
3 + 12 * (5ν - 22) / ((ν - 6) * (ν-8)) for ν >8, else a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_chi_squared_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_chi_squared_dist.references"></a></span><a class="link" href="inverse_chi_squared_dist.html#math_toolkit.dist_ref.dists.inverse_chi_squared_dist.references">References</a>
|
||||
</h5>
|
||||
<div class="orderedlist"><ol class="orderedlist" type="1">
|
||||
<li class="listitem">
|
||||
Bayesian Data Analysis, Andrew Gelman, John B. Carlin, Hal S. Stern,
|
||||
Donald B. Rubin, ISBN-13: 978-1584883883, Chapman & Hall; 2 edition
|
||||
(29 July 2003).
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Bayesian Computation with R, Jim Albert, ISBN-13: 978-0387922973, Springer;
|
||||
2nd ed. edition (10 Jun 2009)
|
||||
</li>
|
||||
</ol></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="hypergeometric_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="inverse_gamma_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,367 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Inverse Gamma Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="inverse_chi_squared_dist.html" title="Inverse Chi Squared Distribution">
|
||||
<link rel="next" href="inverse_gaussian_dist.html" title="Inverse Gaussian (or Inverse Normal) Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="inverse_chi_squared_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="inverse_gaussian_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_gamma_dist"></a><a class="link" href="inverse_gamma_dist.html" title="Inverse Gamma Distribution">Inverse
|
||||
Gamma Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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_gamma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">inverse_gamma_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">inverse_gamma_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">shape</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="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<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="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The inverse_gamma distribution is a continuous probability distribution
|
||||
of the reciprocal of a variable distributed according to the gamma distribution.
|
||||
</p>
|
||||
<p>
|
||||
The inverse_gamma distribution is used in Bayesian statistics.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://en.wikipedia.org/wiki/Inverse-gamma_distribution" target="_top">inverse
|
||||
gamma distribution</a>.
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://rss.acs.unt.edu/Rdoc/library/pscl/html/igamma.html" target="_top">R
|
||||
inverse gamma distribution functions</a>.
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://reference.wolfram.com/mathematica/ref/InverseGammaDistribution.html" target="_top">Wolfram
|
||||
inverse gamma distribution</a>.
|
||||
</p>
|
||||
<p>
|
||||
See also <a class="link" href="gamma_dist.html" title="Gamma (and Erlang) Distribution">Gamma Distribution</a>.
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
In spite of potential confusion with the inverse gamma function, this
|
||||
distribution <span class="bold"><strong>does</strong></span> provide the typedef:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">inverse_gamma_distribution</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">gamma</span><span class="special">;</span></pre>
|
||||
<p>
|
||||
If you want a <code class="computeroutput"><span class="keyword">double</span></code> precision
|
||||
gamma distribution you can use
|
||||
</p>
|
||||
<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_gamma_distribution</span><span class="special"><></span></pre>
|
||||
<p>
|
||||
or you can write <code class="computeroutput"><span class="identifier">inverse_gamma</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></code>
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
For shape parameter α and scale parameter β, it is defined by the probability
|
||||
density function (PDF):
|
||||
</p>
|
||||
<p>
|
||||
   f(x;α, β) = β<sup>α</sup> * (1/x) <sup>α+1</sup> exp(-β/x) / Γ(α)
|
||||
</p>
|
||||
<p>
|
||||
and cumulative density function (CDF)
|
||||
</p>
|
||||
<p>
|
||||
   F(x;α, β) = Γ(α, β/x) / Γ(α)
|
||||
</p>
|
||||
<p>
|
||||
The following graphs illustrate how the PDF and CDF of the inverse gamma
|
||||
distribution varies as the parameters vary:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/inverse_gamma_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/inverse_gamma_cdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_gamma_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_gamma_dist.member_functions"></a></span><a class="link" href="inverse_gamma_dist.html#math_toolkit.dist_ref.dists.inverse_gamma_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">inverse_gamma_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">shape</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>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs an inverse gamma distribution with shape α and scale β.
|
||||
</p>
|
||||
<p>
|
||||
Requires that the shape and scale parameters are greater than zero, otherwise
|
||||
calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the α shape parameter of this inverse gamma distribution.
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the β scale parameter of this inverse gamma distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_gamma_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_gamma_dist.non_member_accessors"></a></span><a class="link" href="inverse_gamma_dist.html#math_toolkit.dist_ref.dists.inverse_gamma_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variate is [0,+∞].
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
Unlike some definitions, this implementation supports a random variate
|
||||
equal to zero as a special case, returning zero for pdf and cdf.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_gamma_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_gamma_dist.accuracy"></a></span><a class="link" href="inverse_gamma_dist.html#math_toolkit.dist_ref.dists.inverse_gamma_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The inverse gamma distribution is implemented in terms of the incomplete
|
||||
gamma functions <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_p</a>
|
||||
and <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_q</a> and their
|
||||
inverses <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_p_inv</a>
|
||||
and <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_q_inv</a>:
|
||||
refer to the accuracy data for those functions for more information. But
|
||||
in general, inverse_gamma results are accurate to a few epsilon, >14
|
||||
decimal digits accuracy for 64-bit double.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_gamma_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.inverse_gamma_dist.implementation"></a></span><a class="link" href="inverse_gamma_dist.html#math_toolkit.dist_ref.dists.inverse_gamma_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table α is the shape parameter of the distribution, α   is its
|
||||
scale parameter, <span class="emphasis"><em>x</em></span> is the random variate, <span class="emphasis"><em>p</em></span>
|
||||
is the probability and <span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = <a class="link" href="../../sf_gamma/gamma_derivatives.html" title="Derivative of the Incomplete Gamma Function">gamma_p_derivative</a>(α,
|
||||
β/ x, β) / x * x
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: p = <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_q</a>(α,
|
||||
β / x)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_p</a>(α,
|
||||
β / x)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = β  / <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_q_inv</a>(α,
|
||||
p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = α  / <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_p_inv</a>(α,
|
||||
q)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
β / (α + 1)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
median
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
no analytic equation is known, but is evaluated as quantile(0.5)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
β / (α - 1) for α > 1, else a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(β * β) / ((α - 1) * (α - 1) * (α - 2)) for α >2, else a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
4 * sqrt (α -2) / (α -3) for α >3, else a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis_excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(30 * α - 66) / ((α-3)*(α - 4)) for α >4, else a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="inverse_chi_squared_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="inverse_gaussian_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,445 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Inverse Gaussian (or Inverse Normal) Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="inverse_gamma_dist.html" title="Inverse Gamma Distribution">
|
||||
<link rel="next" href="laplace_dist.html" title="Laplace Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<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>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<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
|
||||
Gaussian (or Inverse Normal) Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">inverse_gaussian_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<span class="special">};</span>
|
||||
<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>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespace boost // namespace math</span>
|
||||
</pre>
|
||||
<p>
|
||||
The Inverse Gaussian distribution distribution is a continuous probability
|
||||
distribution.
|
||||
</p>
|
||||
<p>
|
||||
The distribution is also called 'normal-inverse Gaussian distribution',
|
||||
and 'normal Inverse' distribution.
|
||||
</p>
|
||||
<p>
|
||||
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 <a href="http://en.wikipedia.org/wiki/Tweedie_distributions" target="_top">Tweedie
|
||||
distributions</a>.
|
||||
</p>
|
||||
<p>
|
||||
(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).
|
||||
</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
<p>
|
||||
Examples are returns from financial assets and turbulent wind speeds.
|
||||
</p>
|
||||
<p>
|
||||
The normal-inverse Gaussian distributions form a subclass of the generalised
|
||||
hyperbolic distributions.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://en.wikipedia.org/wiki/Normal-inverse_Gaussian_distribution" target="_top">distribution</a>.
|
||||
<a href="http://mathworld.wolfram.com/InverseGaussianDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Inverse Gaussian Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</p>
|
||||
<p>
|
||||
If you want a <code class="computeroutput"><span class="keyword">double</span></code> precision
|
||||
inverse_gaussian distribution you can use
|
||||
</p>
|
||||
<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>
|
||||
<p>
|
||||
or, more conveniently, you can write
|
||||
</p>
|
||||
<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>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
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):
|
||||
</p>
|
||||
<p>
|
||||
   f(x;μ, λ) = √(λ/2πx<sup>3</sup>) e<sup>-λ(x-μ)²/2μ²x</sup>
|
||||
</p>
|
||||
<p>
|
||||
and Cumulative Density Function (CDF):
|
||||
</p>
|
||||
<p>
|
||||
   F(x;μ, λ) = Φ{√(λ<span class="emphasis"><em>x) (x</em></span>μ-1)} + e<sup>2μ/λ</sup> Φ{-√(λ/μ) (1+x/μ)}
|
||||
</p>
|
||||
<p>
|
||||
where Φ is the standard normal distribution CDF.
|
||||
</p>
|
||||
<p>
|
||||
The following graphs illustrate how the PDF and CDF of the inverse_gaussian
|
||||
distribution varies for a few values of parameters μ and λ:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/inverse_gaussian_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/inverse_gaussian_cdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h0"></a>
|
||||
<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
|
||||
Functions</a>
|
||||
</h5>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs an inverse_gaussian distribution with μ mean, and scale λ, with
|
||||
both default values 1.
|
||||
</p>
|
||||
<p>
|
||||
Requires that both the mean μ parameter and scale λ are greater than zero,
|
||||
otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the mean μ parameter of this distribution.
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the scale λ parameter of this distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h1"></a>
|
||||
<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
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variate is [0,+∞).
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
Unlike some definitions, this implementation supports a random variate
|
||||
equal to zero as a special case, returning zero for both pdf and cdf.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h2"></a>
|
||||
<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>
|
||||
</h5>
|
||||
<p>
|
||||
The inverse_gaussian distribution is implemented in terms of the exponential
|
||||
function and standard normal distribution <span class="emphasis"><em>N</em></span>0,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 64-bit double.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h3"></a>
|
||||
<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>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table μ is the mean parameter and λ is the scale parameter
|
||||
of the inverse_gaussian distribution, <span class="emphasis"><em>x</em></span> is the random
|
||||
variate, <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q = 1-p</em></span>
|
||||
its complement. Parameters μ for shape and λ for scale are used for the inverse
|
||||
gaussian function.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
√(λ/ 2πx<sup>3</sup>) e<sup>-λ(x - μ)²/ 2μ²x</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Φ{√(λ<span class="emphasis"><em>x) (x</em></span>μ-1)} + e<sup>2μ/λ</sup> Φ{-√(λ/μ) (1+x/μ)}
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
using complement of Φ above.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
No closed form known. Estimated using a guess refined by Newton-Raphson
|
||||
iteration.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
No closed form known. Estimated using a guess refined by Newton-Raphson
|
||||
iteration.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
μ {√(1+9μ²/4λ²)² - 3μ/2λ}
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
median
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
No closed form analytic equation is known, but is evaluated as
|
||||
quantile(0.5)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
μ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
μ³/λ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
3 √ (μ/λ)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis_excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
15μ/λ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12μ/λ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.inverse_gaussian_dist.h4"></a>
|
||||
<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>
|
||||
</h5>
|
||||
<div class="orderedlist"><ol class="orderedlist" type="1">
|
||||
<li class="listitem">
|
||||
Wald, A. (1947). Sequential analysis. Wiley, NY.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
The Inverse Gaussian distribution : theory, methodology, and applications,
|
||||
Raj S. Chhikara, J. Leroy Folks. ISBN 0824779975 (1989).
|
||||
</li>
|
||||
<li class="listitem">
|
||||
The Inverse Gaussian distribution : statistical theory and applications,
|
||||
Seshadri, V , ISBN - 0387986189 (pbk) (Dewey 519.2) (1998).
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.wald.html" target="_top">Numpy
|
||||
and Scipy Documentation</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://bm2.genes.nig.ac.jp/RGM2/R_current/library/statmod/man/invgauss.html" target="_top">R
|
||||
statmod invgauss functions</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://cran.r-project.org/web/packages/SuppDists/index.html" target="_top">R
|
||||
SuppDists invGauss functions</a>. (Note that these R implementations
|
||||
names differ in case).
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.statsci.org/s/invgauss.html" target="_top">StatSci.org invgauss
|
||||
help</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.statsci.org/s/invgauss.statSci.org" target="_top">invgauss
|
||||
R source</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.biostat.wustl.edu/archives/html/s-news/2001-12/msg00144.html" target="_top">pwald,
|
||||
qwald</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.brighton-webs.co.uk/distributions/wald.asp" target="_top">Brighton
|
||||
Webs wald</a>.
|
||||
</li>
|
||||
</ol></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<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>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,360 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Laplace Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="inverse_gaussian_dist.html" title="Inverse Gaussian (or Inverse Normal) Distribution">
|
||||
<link rel="next" href="logistic_dist.html" title="Logistic Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="inverse_gaussian_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="logistic_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.laplace_dist"></a><a class="link" href="laplace_dist.html" title="Laplace Distribution">Laplace Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">laplace</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">laplace_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">laplace_distribution</span><span class="special"><></span> <span class="identifier">laplace</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">laplace_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
<span class="comment">// Construct:</span>
|
||||
<span class="identifier">laplace_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</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">// Accessors:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<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="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
Laplace distribution is the distribution of differences between two independent
|
||||
variates with identical exponential distributions (Abramowitz and Stegun
|
||||
1972, p. 930). It is also called the double exponential distribution.
|
||||
</p>
|
||||
<p>
|
||||
For location parameter μ   and scale parameter σ  , it is defined by the probability
|
||||
density function:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/laplace_pdf.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
The location and scale parameters are equivalent to the mean and standard
|
||||
deviation of the normal or Gaussian distribution.
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates the effect of the parameters μ   and σ   on the
|
||||
PDF. Note that the domain of the random variable remains [-∞,+∞] irrespective
|
||||
of the value of the location parameter:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/laplace_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.laplace_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.laplace_dist.member_functions"></a></span><a class="link" href="laplace_dist.html#math_toolkit.dist_ref.dists.laplace_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">laplace_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</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>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a laplace distribution with location <span class="emphasis"><em>location</em></span>
|
||||
and scale <span class="emphasis"><em>scale</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
The location parameter is the same as the mean of the random variate.
|
||||
</p>
|
||||
<p>
|
||||
The scale parameter is proportional to the standard deviation of the random
|
||||
variate.
|
||||
</p>
|
||||
<p>
|
||||
Requires that the scale parameter is greater than zero, otherwise calls
|
||||
<a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>location</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>scale</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.laplace_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.laplace_dist.non_member_accessors"></a></span><a class="link" href="laplace_dist.html#math_toolkit.dist_ref.dists.laplace_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [-∞,+∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.laplace_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.laplace_dist.accuracy"></a></span><a class="link" href="laplace_dist.html#math_toolkit.dist_ref.dists.laplace_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The laplace distribution is implemented in terms of the standard library
|
||||
log and exp functions and as such should have very small errors.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.laplace_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.laplace_dist.implementation"></a></span><a class="link" href="laplace_dist.html#math_toolkit.dist_ref.dists.laplace_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table μ is the location parameter of the distribution, σ is
|
||||
its scale parameter, <span class="emphasis"><em>x</em></span> is the random variate, <span class="emphasis"><em>p</em></span>
|
||||
is the probability and its complement <span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = e<sup>-abs(x-μ) / σ</sup> / (2 * σ)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relations:
|
||||
</p>
|
||||
<p>
|
||||
x < μ : p = e<sup>(x-μ)/σ </sup> / σ
|
||||
</p>
|
||||
<p>
|
||||
x >= μ : p = 1 - e<sup>(μ-x)/σ </sup> / σ
|
||||
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation:
|
||||
</p>
|
||||
<p>
|
||||
-x < μ : q = e<sup>(-x-μ)/σ </sup> / σ
|
||||
</p>
|
||||
<p>
|
||||
-x >= μ : q = 1 - e<sup>(μ+x)/σ </sup> / σ
|
||||
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relations:
|
||||
</p>
|
||||
<p>
|
||||
p < 0.5 : x = μ + σ * log(2*p)
|
||||
</p>
|
||||
<p>
|
||||
p >= 0.5 : x = μ - σ * log(2-2*p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation:
|
||||
</p>
|
||||
<p>
|
||||
q > 0.5: x = μ + σ*log(2-2*q)
|
||||
</p>
|
||||
<p>
|
||||
q <=0.5: x = μ - σ*log( 2*q )
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
μ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
2 * σ<sup>2</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
μ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
0
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
6
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
3
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.laplace_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.laplace_dist.references"></a></span><a class="link" href="laplace_dist.html#math_toolkit.dist_ref.dists.laplace_dist.references">References</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://mathworld.wolfram.com/LaplaceDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Laplace Distribution."</a> From MathWorld--A
|
||||
Wolfram Web Resource.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://en.wikipedia.org/wiki/Laplace_distribution" target="_top">Laplace
|
||||
Distribution</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions,
|
||||
1972, p. 930.
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="inverse_gaussian_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="logistic_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,298 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Logistic Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="laplace_dist.html" title="Laplace Distribution">
|
||||
<link rel="next" href="lognormal_dist.html" title="Log Normal Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="laplace_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="lognormal_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.logistic_dist"></a><a class="link" href="logistic_dist.html" title="Logistic Distribution">Logistic
|
||||
Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">logistic</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">logistic_distribution</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <span class="identifier">Policy</span><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">logistic_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
<span class="comment">// Construct:</span>
|
||||
<span class="identifier">logistic_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</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">// Accessors:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// location.</span>
|
||||
<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">// scale.</span>
|
||||
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">logistic_distribution</span><span class="special"><></span> <span class="identifier">logistic</span><span class="special">;</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The logistic distribution is a continous probability distribution. It has
|
||||
two parameters - location and scale. The cumulative distribution function
|
||||
of the logistic distribution appears in logistic regression and feedforward
|
||||
neural networks. Among other applications, United State Chess Federation
|
||||
and FIDE use it to calculate chess ratings.
|
||||
</p>
|
||||
<p>
|
||||
The following graph shows how the distribution changes as the parameters
|
||||
change:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/logistic_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.logistic_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.logistic_dist.member_functions"></a></span><a class="link" href="logistic_dist.html#math_toolkit.dist_ref.dists.logistic_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">logistic_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">u</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">s</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a logistic distribution with location <span class="emphasis"><em>u</em></span>
|
||||
and scale <span class="emphasis"><em>s</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Requires <code class="computeroutput"><span class="identifier">scale</span> <span class="special">></span>
|
||||
<span class="number">0</span></code>, otherwise a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
is raised.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the location of this distribution.
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the scale of this distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.logistic_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.logistic_dist.non_member_accessors"></a></span><a class="link" href="logistic_dist.html#math_toolkit.dist_ref.dists.logistic_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [-[max_value], +[min_value]]. However,
|
||||
the pdf and cdf support inputs of +∞ and -∞
|
||||
as special cases if RealType permits.
|
||||
</p>
|
||||
<p>
|
||||
At <code class="computeroutput"><span class="identifier">p</span><span class="special">=</span><span class="number">1</span></code> and <code class="computeroutput"><span class="identifier">p</span><span class="special">=</span><span class="number">0</span></code>, the quantile
|
||||
function returns the result of +<a class="link" href="../../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>
|
||||
and -<a class="link" href="../../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>,
|
||||
while the complement quantile function returns the result of -<a class="link" href="../../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>
|
||||
and +<a class="link" href="../../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>
|
||||
respectively.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.logistic_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.logistic_dist.accuracy"></a></span><a class="link" href="logistic_dist.html#math_toolkit.dist_ref.dists.logistic_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The logistic distribution is implemented in terms of the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span></code> and the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">log</span></code>
|
||||
functions, so its accuracy is related to the accurate implementations of
|
||||
those functions on a given platform. When calculating the quantile with
|
||||
a non-zero <span class="emphasis"><em>position</em></span> parameter catastrophic cancellation
|
||||
errors can occur: in such cases, only a low <span class="emphasis"><em>absolute error</em></span>
|
||||
can be guaranteed.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.logistic_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.logistic_dist.implementation"></a></span><a class="link" href="logistic_dist.html#math_toolkit.dist_ref.dists.logistic_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = e<sup>-(x-u)/s</sup> / (s*(1+e<sup>-(x-u)/s</sup>)<sup>2</sup>)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: p = 1/(1+e<sup>-(x-u)/s</sup>)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = 1/(1+e<sup>(x-u)/s</sup>)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = u - s*log(1/p-1)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = u + s*log(p/1-p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
u
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The same as the mean.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
0
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
6/5
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(π*s)<sup>2</sup> / 3
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="laplace_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="lognormal_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,330 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Log Normal Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="logistic_dist.html" title="Logistic Distribution">
|
||||
<link rel="next" href="negative_binomial_dist.html" title="Negative Binomial Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="logistic_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="negative_binomial_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.lognormal_dist"></a><a class="link" href="lognormal_dist.html" title="Log Normal Distribution">Log Normal
|
||||
Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">lognormal</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">lognormal_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">lognormal_distribution</span><span class="special"><></span> <span class="identifier">lognormal</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">lognormal_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
<span class="comment">// Construct:</span>
|
||||
<span class="identifier">lognormal_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</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">// Accessors:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<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="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The lognormal distribution is the distribution that arises when the logarithm
|
||||
of the random variable is normally distributed. A lognormal distribution
|
||||
results when the variable is the product of a large number of independent,
|
||||
identically-distributed variables.
|
||||
</p>
|
||||
<p>
|
||||
For location and scale parameters <span class="emphasis"><em>m</em></span> and <span class="emphasis"><em>s</em></span>
|
||||
it is defined by the probability density function:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/lognormal_ref.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
The location and scale parameters are equivalent to the mean and standard
|
||||
deviation of the logarithm of the random variable.
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates the effect of the location parameter on
|
||||
the PDF, note that the range of the random variable remains [0,+∞] irrespective
|
||||
of the value of the location parameter:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/lognormal_pdf1.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
The next graph illustrates the effect of the scale parameter on the PDF:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/lognormal_pdf2.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.lognormal_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.lognormal_dist.member_functions"></a></span><a class="link" href="lognormal_dist.html#math_toolkit.dist_ref.dists.lognormal_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">lognormal_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</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>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a lognormal distribution with location <span class="emphasis"><em>location</em></span>
|
||||
and scale <span class="emphasis"><em>scale</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
The location parameter is the same as the mean of the logarithm of the
|
||||
random variate.
|
||||
</p>
|
||||
<p>
|
||||
The scale parameter is the same as the standard deviation of the logarithm
|
||||
of the random variate.
|
||||
</p>
|
||||
<p>
|
||||
Requires that the scale parameter is greater than zero, otherwise calls
|
||||
<a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>location</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>scale</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.lognormal_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.lognormal_dist.non_member_accessors"></a></span><a class="link" href="lognormal_dist.html#math_toolkit.dist_ref.dists.lognormal_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [0,+∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.lognormal_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.lognormal_dist.accuracy"></a></span><a class="link" href="lognormal_dist.html#math_toolkit.dist_ref.dists.lognormal_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The lognormal distribution is implemented in terms of the standard library
|
||||
log and exp functions, plus the <a class="link" href="../../sf_erf/error_function.html" title="Error Functions">error
|
||||
function</a>, and as such should have very low error rates.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.lognormal_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.lognormal_dist.implementation"></a></span><a class="link" href="lognormal_dist.html#math_toolkit.dist_ref.dists.lognormal_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table <span class="emphasis"><em>m</em></span> is the location parameter
|
||||
of the distribution, <span class="emphasis"><em>s</em></span> is its scale parameter, <span class="emphasis"><em>x</em></span>
|
||||
is the random variate, <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q
|
||||
= 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = e<sup>-(ln(x) - m)<sup>2 </sup> / 2s<sup>2 </sup> </sup> / (x * s * sqrt(2pi))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: p = cdf(normal_distribtion<RealType>(m,
|
||||
s), log(x))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = cdf(complement(normal_distribtion<RealType>(m,
|
||||
s), log(x)))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = exp(quantile(normal_distribtion<RealType>(m,
|
||||
s), p))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = exp(quantile(complement(normal_distribtion<RealType>(m,
|
||||
s), q)))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
e<sup>m + s<sup>2 </sup> / 2 </sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(e<sup>s<sup>2</sup> </sup> - 1) * e<sup>2m + s<sup>2 </sup> </sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
e<sup>m - s<sup>2 </sup> </sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
sqrt(e<sup>s<sup>2</sup> </sup> - 1) * (2 + e<sup>s<sup>2</sup> </sup>)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
e<sup>4s<sup>2</sup> </sup> + 2e<sup>3s<sup>2</sup> </sup> + 3e<sup>2s<sup>2</sup> </sup> - 3
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
e<sup>4s<sup>2</sup> </sup> + 2e<sup>3s<sup>2</sup> </sup> + 3e<sup>2s<sup>2</sup> </sup> - 6
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="logistic_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="negative_binomial_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,484 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Noncentral Beta Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="negative_binomial_dist.html" title="Negative Binomial Distribution">
|
||||
<link rel="next" href="nc_chi_squared_dist.html" title="Noncentral Chi-Squared Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="negative_binomial_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="nc_chi_squared_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.nc_beta_dist"></a><a class="link" href="nc_beta_dist.html" title="Noncentral Beta Distribution">Noncentral
|
||||
Beta Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">non_central_beta</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">non_central_beta_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">non_central_beta_distribution</span><span class="special"><></span> <span class="identifier">non_central_beta</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">non_central_beta_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Constructor:</span>
|
||||
<span class="identifier">non_central_beta_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// Accessor to shape parameters:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Accessor to non-centrality parameter lambda:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">non_centrality</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The noncentral beta distribution is a generalization of the <a class="link" href="beta_dist.html" title="Beta Distribution">Beta
|
||||
Distribution</a>.
|
||||
</p>
|
||||
<p>
|
||||
It is defined as the ratio X = χ<sub>m</sub><sup>2</sup>(λ) / (χ<sub>m</sub><sup>2</sup>(λ) + χ<sub>n</sub><sup>2</sup>) where χ<sub>m</sub><sup>2</sup>(λ) is a noncentral
|
||||
χ<sup>2</sup>
|
||||
random variable with <span class="emphasis"><em>m</em></span> degrees of freedom, and χ<sub>n</sub><sup>2</sup>
|
||||
is
|
||||
a central χ<sup>2</sup> random variable with <span class="emphasis"><em>n</em></span> degrees of freedom.
|
||||
</p>
|
||||
<p>
|
||||
This gives a PDF that can be expressed as a Poisson mixture of beta distribution
|
||||
PDFs:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_beta_ref1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
where P(i;λ/2) is the discrete Poisson probablity at <span class="emphasis"><em>i</em></span>,
|
||||
with mean λ/2, and I<sub>x</sub><sup>'</sup>(α, β) is the derivative of the incomplete beta function.
|
||||
This leads to the usual form of the CDF as:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_beta_ref2.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates how the distribution changes for different
|
||||
values of λ:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/nc_beta_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_beta_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_beta_dist.member_functions"></a></span><a class="link" href="nc_beta_dist.html#math_toolkit.dist_ref.dists.nc_beta_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">non_central_beta_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a noncentral beta distribution with shape parameters <span class="emphasis"><em>a</em></span>
|
||||
and <span class="emphasis"><em>b</em></span> and non-centrality parameter <span class="emphasis"><em>lambda</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Requires a > 0, b > 0 and lambda >= 0, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>a</em></span> from which this object was
|
||||
constructed.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>b</em></span> from which this object was
|
||||
constructed.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">non_centrality</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>lambda</em></span> from which this object
|
||||
was constructed.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_beta_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_beta_dist.non_member_accessors"></a></span><a class="link" href="nc_beta_dist.html#math_toolkit.dist_ref.dists.nc_beta_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
Most of the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member
|
||||
accessor functions</a> are supported: <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative
|
||||
Distribution Function</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability
|
||||
Density Function</a>, <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.mean">mean</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.variance">variance</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.median">median</a>, <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.hazard">Hazard Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard Function</a>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
Mean and variance are implemented using hypergeometric pfq functions and
|
||||
relations given in <a href="http://reference.wolfram.com/mathematica/ref/NoncentralBetaDistribution.html" target="_top">Wolfram
|
||||
Noncentral Beta Distribution</a>.
|
||||
</p>
|
||||
<p>
|
||||
However, the following are not currently implemented: <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> and
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess</a>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [0, 1].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_beta_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_beta_dist.accuracy"></a></span><a class="link" href="nc_beta_dist.html#math_toolkit.dist_ref.dists.nc_beta_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The following table shows the peak errors (in units of <a href="http://en.wikipedia.org/wiki/Machine_epsilon" target="_top">epsilon</a>)
|
||||
found on various platforms with various floating point types. The failures
|
||||
in the comparison to the <a href="http://www.r-project.org/" target="_top">R Math
|
||||
library</a>, seem to be mostly in the corner cases when the probablity
|
||||
would be very small. Unless otherwise specified any floating-point type
|
||||
that is narrower than the one shown will have <a class="link" href="../../relative_error.html#math_toolkit.relative_error.zero_error">effectively
|
||||
zero error</a>.
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="math_toolkit.dist_ref.dists.nc_beta_dist.table_non_central_beta_CDF"></a><p class="title"><b>Table 5.4. Error rates for non central beta CDF</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Error rates for non central beta CDF">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Microsoft Visual C++ version 12.0<br> Win32<br> double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
GNU C++ version 5.1.0<br> linux<br> double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
GNU C++ version 5.1.0<br> linux<br> long double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Sun compiler version 0x5130<br> Sun Solaris<br> long double
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central Beta, medium parameters
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 240ε (Mean = 31ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 0.998ε (Mean = 0.0659ε)</span><br>
|
||||
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max
|
||||
= 1.46e+26ε (Mean = 3.5e+24ε) <a class="link" href="../../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_non_central_beta_CDF_Rmath_3_0_2_Non_Central_Beta_medium_parameters">And
|
||||
other failures.</a>)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 825ε (Mean = 27.4ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 832ε (Mean = 38.1ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central Beta, large parameters
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 3.41e+003ε (Mean = 475ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 1.18ε (Mean = 0.175ε)</span><br>
|
||||
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max
|
||||
= 1.01e+36ε (Mean = 1.19e+35ε) <a class="link" href="../../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_non_central_beta_CDF_Rmath_3_0_2_Non_Central_Beta_large_parameters">And
|
||||
other failures.</a>)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 2.5e+04ε (Mean = 3.78e+03ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 2.57e+04ε (Mean = 4.43e+03ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break"><div class="table">
|
||||
<a name="math_toolkit.dist_ref.dists.nc_beta_dist.table_non_central_beta_CDF_complement"></a><p class="title"><b>Table 5.5. Error rates for non central beta CDF complement</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Error rates for non central beta CDF complement">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Microsoft Visual C++ version 12.0<br> Win32<br> double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
GNU C++ version 5.1.0<br> linux<br> double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
GNU C++ version 5.1.0<br> linux<br> long double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Sun compiler version 0x5130<br> Sun Solaris<br> long double
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central Beta, medium parameters
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 619ε (Mean = 62.7ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 0.998ε (Mean = 0.0957ε)</span><br>
|
||||
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max
|
||||
= 7.5e+97ε (Mean = 1.37e+96ε) <a class="link" href="../../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_non_central_beta_CDF_complement_Rmath_3_0_2_Non_Central_Beta_medium_parameters">And
|
||||
other failures.</a>)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 396ε (Mean = 50.7ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 554ε (Mean = 57.3ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central Beta, large parameters
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 8.67e+003ε (Mean = 1.04e+003ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 0.986ε (Mean = 0.188ε)</span><br>
|
||||
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max
|
||||
= +INFε (Mean = +INFε) <a class="link" href="../../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_non_central_beta_CDF_complement_Rmath_3_0_2_Non_Central_Beta_large_parameters">And
|
||||
other failures.</a>)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 6.83e+03ε (Mean = 993ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 3.56e+03ε (Mean = 704ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break"><p>
|
||||
Error rates for the PDF, the complement of the CDF and for the quantile
|
||||
functions are broadly similar.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_beta_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_beta_dist.tests"></a></span><a class="link" href="nc_beta_dist.html#math_toolkit.dist_ref.dists.nc_beta_dist.tests">Tests</a>
|
||||
</h5>
|
||||
<p>
|
||||
There are two sets of test data used to verify this implementation: firstly
|
||||
we can compare with a few sample values generated by the <a href="http://www.r-project.org/" target="_top">R
|
||||
library</a>. Secondly, we have tables of test data, computed with this
|
||||
implementation and using interval arithmetic - this data should be accurate
|
||||
to at least 50 decimal digits - and is the used for our accuracy tests.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_beta_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_beta_dist.implementation"></a></span><a class="link" href="nc_beta_dist.html#math_toolkit.dist_ref.dists.nc_beta_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
The CDF and its complement are evaluated as follows:
|
||||
</p>
|
||||
<p>
|
||||
First we determine which of the two values (the CDF or its complement)
|
||||
is likely to be the smaller, the crossover point is taken to be the mean
|
||||
of the distribution: for this we use the approximation due to: R. Chattamvelli
|
||||
and R. Shanmugam, "Algorithm AS 310: Computing the Non-Central Beta
|
||||
Distribution Function", Applied Statistics, Vol. 46, No. 1. (1997),
|
||||
pp. 146-156.
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_beta_ref3.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
Then either the CDF or its complement is computed using the relations:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_beta_ref4.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
The summation is performed by starting at i = λ/2, and then recursing in
|
||||
both directions, using the usual recurrence relations for the Poisson PDF
|
||||
and incomplete beta functions. This is the "Method 2" described
|
||||
by:
|
||||
</p>
|
||||
<p>
|
||||
Denise Benton and K. Krishnamoorthy, "Computing discrete mixtures
|
||||
of continuous distributions: noncentral chisquare, noncentral t and the
|
||||
distribution of the square of the sample multiple correlation coefficient",
|
||||
Computational Statistics & Data Analysis 43 (2003) 249-267.
|
||||
</p>
|
||||
<p>
|
||||
Specific applications of the above formulae to the noncentral beta distribution
|
||||
can be found in:
|
||||
</p>
|
||||
<p>
|
||||
Russell V. Lenth, "Algorithm AS 226: Computing Noncentral Beta Probabilities",
|
||||
Applied Statistics, Vol. 36, No. 2. (1987), pp. 241-244.
|
||||
</p>
|
||||
<p>
|
||||
H. Frick, "Algorithm AS R84: A Remark on Algorithm AS 226: Computing
|
||||
Non-Central Beta Probabilities", Applied Statistics, Vol. 39, No.
|
||||
2. (1990), pp. 311-312.
|
||||
</p>
|
||||
<p>
|
||||
Ming Long Lam, "Remark AS R95: A Remark on Algorithm AS 226: Computing
|
||||
Non-Central Beta Probabilities", Applied Statistics, Vol. 44, No.
|
||||
4. (1995), pp. 551-552.
|
||||
</p>
|
||||
<p>
|
||||
Harry O. Posten, "An Effective Algorithm for the Noncentral Beta Distribution
|
||||
Function", The American Statistician, Vol. 47, No. 2. (May, 1993),
|
||||
pp. 129-131.
|
||||
</p>
|
||||
<p>
|
||||
R. Chattamvelli, "A Note on the Noncentral Beta Distribution Function",
|
||||
The American Statistician, Vol. 49, No. 2. (May, 1995), pp. 231-234.
|
||||
</p>
|
||||
<p>
|
||||
Of these, the Posten reference provides the most complete overview, and
|
||||
includes the modification starting iteration at λ/2.
|
||||
</p>
|
||||
<p>
|
||||
The main difference between this implementation and the above references
|
||||
is the direct computation of the complement when most efficient to do so,
|
||||
and the accumulation of the sum to -1 rather than subtracting the result
|
||||
from 1 at the end: this can substantially reduce the number of iterations
|
||||
required when the result is near 1.
|
||||
</p>
|
||||
<p>
|
||||
The PDF is computed using the methodology of Benton and Krishnamoorthy
|
||||
and the relation:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_beta_ref1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
Quantiles are computed using a specially modified version of <a class="link" href="../../roots/roots_noderiv/bracket_solve.html" title="Bracket and Solve Root">bracket
|
||||
and solve</a>, starting the search for the root at the mean of the distribution.
|
||||
(A Cornish-Fisher type expansion was also tried, but while this gets quite
|
||||
close to the root in many cases, when it is wrong it tends to introduce
|
||||
quite pathological behaviour: more investigation in this area is probably
|
||||
warranted).
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="negative_binomial_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="nc_chi_squared_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,572 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Noncentral Chi-Squared Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="nc_beta_dist.html" title="Noncentral Beta Distribution">
|
||||
<link rel="next" href="nc_f_dist.html" title="Noncentral F Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="nc_beta_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="nc_f_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist"></a><a class="link" href="nc_chi_squared_dist.html" title="Noncentral Chi-Squared Distribution">Noncentral
|
||||
Chi-Squared Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">non_central_chi_squared</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">non_central_chi_squared_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">non_central_chi_squared_distribution</span><span class="special"><></span> <span class="identifier">non_central_chi_squared</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">non_central_chi_squared_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Constructor:</span>
|
||||
<span class="identifier">non_central_chi_squared_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// Accessor to degrees of freedom parameter v:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Accessor to non centrality parameter lambda:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">non_centrality</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Parameter finders:</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_degrees_of_freedom</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">A</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">B</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">C</span><span class="special">></span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_degrees_of_freedom</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">complemented3_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">C</span><span class="special">>&</span> <span class="identifier">c</span><span class="special">);</span>
|
||||
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_non_centrality</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">A</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">B</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">C</span><span class="special">></span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_non_centrality</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">complemented3_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">C</span><span class="special">>&</span> <span class="identifier">c</span><span class="special">);</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The noncentral chi-squared distribution is a generalization of the <a class="link" href="chi_squared_dist.html" title="Chi Squared Distribution">Chi Squared Distribution</a>.
|
||||
If X<sub>i</sub> are ν independent, normally distributed random variables with means
|
||||
μ<sub>i</sub> and variances σ<sub>i</sub><sup>2</sup>, then the random variable
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
is distributed according to the noncentral chi-squared distribution.
|
||||
</p>
|
||||
<p>
|
||||
The noncentral chi-squared distribution has two parameters: ν which specifies
|
||||
the number of degrees of freedom (i.e. the number of X<sub>i</sub>), and λ which is
|
||||
related to the mean of the random variables X<sub>i</sub> by:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref2.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
(Note that some references define λ as one half of the above sum).
|
||||
</p>
|
||||
<p>
|
||||
This leads to a PDF of:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref3.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
where <span class="emphasis"><em>f(x;k)</em></span> is the central chi-squared distribution
|
||||
PDF, and <span class="emphasis"><em>I<sub>v</sub>(x)</em></span> is a modified Bessel function of the
|
||||
first kind.
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates how the distribution changes for different
|
||||
values of λ:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/nccs_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.member_functions"></a></span><a class="link" href="nc_chi_squared_dist.html#math_toolkit.dist_ref.dists.nc_chi_squared_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">non_central_chi_squared_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a Chi-Squared distribution with <span class="emphasis"><em>v</em></span> degrees
|
||||
of freedom and non-centrality parameter <span class="emphasis"><em>lambda</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Requires v > 0 and lambda >= 0, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>v</em></span> from which this object was
|
||||
constructed.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">non_centrality</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>lambda</em></span> from which this object
|
||||
was constructed.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_degrees_of_freedom</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
This function returns the number of degrees of freedom <span class="emphasis"><em>v</em></span>
|
||||
such that: <code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">non_central_chi_squared</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <span class="identifier">Policy</span><span class="special">>(</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">lambda</span><span class="special">),</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">p</span></code>
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">A</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">B</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">C</span><span class="special">></span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_degrees_of_freedom</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">complemented3_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">C</span><span class="special">>&</span> <span class="identifier">c</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
When called with argument <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">lambda</span><span class="special">,</span> <span class="identifier">x</span><span class="special">,</span>
|
||||
<span class="identifier">q</span><span class="special">)</span></code>
|
||||
this function returns the number of degrees of freedom <span class="emphasis"><em>v</em></span>
|
||||
such that:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">non_central_chi_squared</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <span class="identifier">Policy</span><span class="special">>(</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">lambda</span><span class="special">),</span> <span class="identifier">x</span><span class="special">))</span> <span class="special">==</span> <span class="identifier">q</span></code>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_non_centrality</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
This function returns the non centrality parameter <span class="emphasis"><em>lambda</em></span>
|
||||
such that:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">non_central_chi_squared</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <span class="identifier">Policy</span><span class="special">>(</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">lambda</span><span class="special">),</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">p</span></code>
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">A</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">B</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">C</span><span class="special">></span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_non_centrality</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">complemented3_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">C</span><span class="special">>&</span> <span class="identifier">c</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
When called with argument <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">v</span><span class="special">,</span>
|
||||
<span class="identifier">x</span><span class="special">,</span>
|
||||
<span class="identifier">q</span><span class="special">)</span></code>
|
||||
this function returns the non centrality parameter <span class="emphasis"><em>lambda</em></span>
|
||||
such that:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">non_central_chi_squared</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <span class="identifier">Policy</span><span class="special">>(</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">lambda</span><span class="special">),</span> <span class="identifier">x</span><span class="special">))</span> <span class="special">==</span> <span class="identifier">q</span></code>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.non_member_accessors"></a></span><a class="link" href="nc_chi_squared_dist.html#math_toolkit.dist_ref.dists.nc_chi_squared_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [0, +∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.examples"></a></span><a class="link" href="nc_chi_squared_dist.html#math_toolkit.dist_ref.dists.nc_chi_squared_dist.examples">Examples</a>
|
||||
</h5>
|
||||
<p>
|
||||
There is a <a class="link" href="../../stat_tut/weg/nccs_eg.html" title="Non Central Chi Squared Example">worked example</a>
|
||||
for the noncentral chi-squared distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.accuracy"></a></span><a class="link" href="nc_chi_squared_dist.html#math_toolkit.dist_ref.dists.nc_chi_squared_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The following table shows the peak errors (in units of <a href="http://en.wikipedia.org/wiki/Machine_epsilon" target="_top">epsilon</a>)
|
||||
found on various platforms with various floating point types. The failures
|
||||
in the comparison to the <a href="http://www.r-project.org/" target="_top">R Math
|
||||
library</a>, seem to be mostly in the corner cases when the probablity
|
||||
would be very small. Unless otherwise specified any floating-point type
|
||||
that is narrower than the one shown will have <a class="link" href="../../relative_error.html#math_toolkit.relative_error.zero_error">effectively
|
||||
zero error</a>.
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.table_non_central_chi_squared_CDF"></a><p class="title"><b>Table 5.6. Error rates for non central chi squared CDF</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Error rates for non central chi squared CDF">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Microsoft Visual C++ version 12.0<br> Win32<br> double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
GNU C++ version 5.1.0<br> linux<br> double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
GNU C++ version 5.1.0<br> linux<br> long double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Sun compiler version 0x5130<br> Sun Solaris<br> long double
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central Chi Squared, medium parameters
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 48.9ε (Mean = 10ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 0.99ε (Mean = 0.0529ε)</span><br>
|
||||
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 727ε (Mean = 121ε))
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 46.5ε (Mean = 10.3ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 115ε (Mean = 13.9ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central Chi Squared, large parameters
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 9.79e+003ε (Mean = 723ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 1.07ε (Mean = 0.102ε)</span><br>
|
||||
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max
|
||||
= 3.27e+08ε (Mean = 2.23e+07ε))</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 3.07e+03ε (Mean = 336ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 6.17e+03ε (Mean = 677ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break"><div class="table">
|
||||
<a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.table_non_central_chi_squared_CDF_complement"></a><p class="title"><b>Table 5.7. Error rates for non central chi squared CDF complement</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Error rates for non central chi squared CDF complement">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Microsoft Visual C++ version 12.0<br> Win32<br> double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
GNU C++ version 5.1.0<br> linux<br> double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
GNU C++ version 5.1.0<br> linux<br> long double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Sun compiler version 0x5130<br> Sun Solaris<br> long double
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central Chi Squared, medium parameters
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 98.6ε (Mean = 15.8ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 0.96ε (Mean = 0.0635ε)</span><br>
|
||||
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max
|
||||
= +INFε (Mean = +INFε) <a class="link" href="../../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_non_central_chi_squared_CDF_complement_Rmath_3_0_2_Non_Central_Chi_Squared_medium_parameters">And
|
||||
other failures.</a>)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 107ε (Mean = 17.1ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 171ε (Mean = 22.8ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central Chi Squared, large parameters
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 5.43e+003ε (Mean = 705ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 2.11ε (Mean = 0.278ε)</span><br>
|
||||
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max
|
||||
= +INFε (Mean = +INFε) <a class="link" href="../../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_non_central_chi_squared_CDF_complement_Rmath_3_0_2_Non_Central_Chi_Squared_large_parameters">And
|
||||
other failures.</a>)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 5.02e+03ε (Mean = 630ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 5.1e+03ε (Mean = 577ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break"><p>
|
||||
Error rates for the quantile functions are broadly similar. Special mention
|
||||
should go to the <code class="computeroutput"><span class="identifier">mode</span></code> function:
|
||||
there is no closed form for this function, so it is evaluated numerically
|
||||
by finding the maxima of the PDF: in principal this can not produce an
|
||||
accuracy greater than the square root of the machine epsilon.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.tests"></a></span><a class="link" href="nc_chi_squared_dist.html#math_toolkit.dist_ref.dists.nc_chi_squared_dist.tests">Tests</a>
|
||||
</h5>
|
||||
<p>
|
||||
There are two sets of test data used to verify this implementation: firstly
|
||||
we can compare with published data, for example with Table 6 of "Self-Validating
|
||||
Computations of Probabilities for Selected Central and Noncentral Univariate
|
||||
Probability Functions", Morgan C. Wang and William J. Kennedy, Journal
|
||||
of the American Statistical Association, Vol. 89, No. 427. (Sep., 1994),
|
||||
pp. 878-887. Secondly, we have tables of test data, computed with this
|
||||
implementation and using interval arithmetic - this data should be accurate
|
||||
to at least 50 decimal digits - and is the used for our accuracy tests.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.h5"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_chi_squared_dist.implementation"></a></span><a class="link" href="nc_chi_squared_dist.html#math_toolkit.dist_ref.dists.nc_chi_squared_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
The CDF and its complement are evaluated as follows:
|
||||
</p>
|
||||
<p>
|
||||
First we determine which of the two values (the CDF or its complement)
|
||||
is likely to be the smaller: for this we can use the relation due to Temme
|
||||
(see "Asymptotic and Numerical Aspects of the Noncentral Chi-Square
|
||||
Distribution", N. M. Temme, Computers Math. Applic. Vol 25, No. 5,
|
||||
55-63, 1993) that:
|
||||
</p>
|
||||
<p>
|
||||
F(ν,λ;ν+λ) ≈ 0.5
|
||||
</p>
|
||||
<p>
|
||||
and so compute the CDF when the random variable is less than ν+λ, and its
|
||||
complement when the random variable is greater than ν+λ. If necessary the
|
||||
computed result is then subtracted from 1 to give the desired result (the
|
||||
CDF or its complement).
|
||||
</p>
|
||||
<p>
|
||||
For small values of the non centrality parameter, the CDF is computed using
|
||||
the method of Ding (see "Algorithm AS 275: Computing the Non-Central
|
||||
#2 Distribution Function", Cherng G. Ding, Applied Statistics, Vol.
|
||||
41, No. 2. (1992), pp. 478-482). This uses the following series representation:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref4.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
which requires just one call to <a class="link" href="../../sf_gamma/gamma_derivatives.html" title="Derivative of the Incomplete Gamma Function">gamma_p_derivative</a>
|
||||
with the subsequent terms being computed by recursion as shown above.
|
||||
</p>
|
||||
<p>
|
||||
For larger values of the non-centrality parameter, Ding's method can take
|
||||
an unreasonable number of terms before convergence is achieved. Furthermore,
|
||||
the largest term is not the first term, so in extreme cases the first term
|
||||
may be zero, leading to a zero result, even though the true value may be
|
||||
non-zero.
|
||||
</p>
|
||||
<p>
|
||||
Therefore, when the non-centrality parameter is greater than 200, the method
|
||||
due to Krishnamoorthy (see "Computing discrete mixtures of continuous
|
||||
distributions: noncentral chisquare, noncentral t and the distribution
|
||||
of the square of the sample multiple correlation coefficient", Denise
|
||||
Benton and K. Krishnamoorthy, Computational Statistics & Data Analysis,
|
||||
43, (2003), 249-267) is used.
|
||||
</p>
|
||||
<p>
|
||||
This method uses the well known sum:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref5.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
Where P<sub>a</sub>(x) is the incomplete gamma function.
|
||||
</p>
|
||||
<p>
|
||||
The method starts at the λth term, which is where the Poisson weighting
|
||||
function achieves its maximum value, although this is not necessarily the
|
||||
largest overall term. Subsequent terms are calculated via the normal recurrence
|
||||
relations for the incomplete gamma function, and iteration proceeds both
|
||||
forwards and backwards until sufficient precision has been achieved. It
|
||||
should be noted that recurrence in the forwards direction of P<sub>a</sub>(x) is numerically
|
||||
unstable. However, since we always start <span class="emphasis"><em>after</em></span> the
|
||||
largest term in the series, numeric instability is introduced more slowly
|
||||
than the series converges.
|
||||
</p>
|
||||
<p>
|
||||
Computation of the complement of the CDF uses an extension of Krishnamoorthy's
|
||||
method, given that:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref6.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
we can again start at the λ'th term and proceed in both directions from
|
||||
there until the required precision is achieved. This time it is backwards
|
||||
recursion on the incomplete gamma function Q<sub>a</sub>(x) which is unstable. However,
|
||||
as long as we start well <span class="emphasis"><em>before</em></span> the largest term,
|
||||
this is not an issue in practice.
|
||||
</p>
|
||||
<p>
|
||||
The PDF is computed directly using the relation:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref3.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
Where <span class="emphasis"><em>f(x; v)</em></span> is the PDF of the central <a class="link" href="chi_squared_dist.html" title="Chi Squared Distribution">Chi
|
||||
Squared Distribution</a> and <span class="emphasis"><em>I<sub>v</sub>(x)</em></span> is a modified
|
||||
Bessel function, see <a class="link" href="../../bessel/mbessel.html" title="Modified Bessel Functions of the First and Second Kinds">cyl_bessel_i</a>.
|
||||
For small values of the non-centrality parameter the relation in terms
|
||||
of <a class="link" href="../../bessel/mbessel.html" title="Modified Bessel Functions of the First and Second Kinds">cyl_bessel_i</a> is used.
|
||||
However, this method fails for large values of the non-centrality parameter,
|
||||
so in that case the infinite sum is evaluated using the method of Benton
|
||||
and Krishnamoorthy, and the usual recurrence relations for successive terms.
|
||||
</p>
|
||||
<p>
|
||||
The quantile functions are computed by numeric inversion of the CDF. An
|
||||
improve starting quess is from Thomas Luu, <a href="http://discovery.ucl.ac.uk/1482128/%2c" target="_top">Fast
|
||||
and accurate parallel computation of quantile functions for random number
|
||||
generation, Doctorial Thesis, 2016</a>.
|
||||
</p>
|
||||
<p>
|
||||
There is no <a href="http://en.wikipedia.org/wiki/Closed_form" target="_top">closed
|
||||
form</a> for the mode of the noncentral chi-squared distribution: it
|
||||
is computed numerically by finding the maximum of the PDF. Likewise, the
|
||||
median is computed numerically via the quantile.
|
||||
</p>
|
||||
<p>
|
||||
The remaining non-member functions use the following formulas:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_chi_squ_ref7.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
Some analytic properties of noncentral distributions (particularly unimodality,
|
||||
and monotonicity of their modes) are surveyed and summarized by:
|
||||
</p>
|
||||
<p>
|
||||
Andrea van Aubel & Wolfgang Gawronski, Applied Mathematics and Computation,
|
||||
141 (2003) 3-12.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="nc_beta_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="nc_f_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,410 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Noncentral F Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="nc_chi_squared_dist.html" title="Noncentral Chi-Squared Distribution">
|
||||
<link rel="next" href="nc_t_dist.html" title="Noncentral T Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="nc_chi_squared_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="nc_t_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.nc_f_dist"></a><a class="link" href="nc_f_dist.html" title="Noncentral F Distribution">Noncentral F
|
||||
Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">non_central_f</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">non_central_f_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">non_central_f_distribution</span><span class="special"><></span> <span class="identifier">non_central_f</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">non_central_f_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Constructor:</span>
|
||||
<span class="identifier">non_central_f_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v1</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">v2</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// Accessor to degrees_of_freedom parameters v1 & v2:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom1</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom2</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Accessor to non-centrality parameter lambda:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">non_centrality</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The noncentral F distribution is a generalization of the <a class="link" href="f_dist.html" title="F Distribution">Fisher
|
||||
F Distribution</a>. It is defined as the ratio
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">F</span> <span class="special">=</span> <span class="special">(</span><span class="identifier">X</span><span class="special">/</span><span class="identifier">v1</span><span class="special">)</span> <span class="special">/</span> <span class="special">(</span><span class="identifier">Y</span><span class="special">/</span><span class="identifier">v2</span><span class="special">)</span>
|
||||
</pre>
|
||||
<p>
|
||||
where X is a noncentral χ<sup>2</sup>
|
||||
random variable with <span class="emphasis"><em>v1</em></span> degrees
|
||||
of freedom and non-centrality parameter λ, and Y is a central χ<sup>2</sup> random variable
|
||||
with <span class="emphasis"><em>v2</em></span> degrees of freedom.
|
||||
</p>
|
||||
<p>
|
||||
This gives the following PDF:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_f_ref1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
where L<sub>a</sub><sup>b</sup>(c) is a generalised Laguerre polynomial and B(a,b) is the <a class="link" href="../../sf_beta/beta_function.html" title="Beta">beta</a> function, or
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_f_ref2.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates how the distribution changes for different
|
||||
values of λ:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/nc_f_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_f_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_f_dist.member_functions"></a></span><a class="link" href="nc_f_dist.html#math_toolkit.dist_ref.dists.nc_f_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">non_central_f_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v1</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">v2</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a non-central beta distribution with parameters <span class="emphasis"><em>v1</em></span>
|
||||
and <span class="emphasis"><em>v2</em></span> and non-centrality parameter <span class="emphasis"><em>lambda</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Requires v1 > 0, v2 > 0 and lambda >= 0, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom1</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>v1</em></span> from which this object was
|
||||
constructed.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom2</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>v2</em></span> from which this object was
|
||||
constructed.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">non_centrality</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the non-centrality parameter <span class="emphasis"><em>lambda</em></span> from which
|
||||
this object was constructed.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_f_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_f_dist.non_member_accessors"></a></span><a class="link" href="nc_f_dist.html#math_toolkit.dist_ref.dists.nc_f_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [0, +∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_f_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_f_dist.accuracy"></a></span><a class="link" href="nc_f_dist.html#math_toolkit.dist_ref.dists.nc_f_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
This distribution is implemented in terms of the <a class="link" href="nc_beta_dist.html" title="Noncentral Beta Distribution">Noncentral
|
||||
Beta Distribution</a>: refer to that distribution for accuracy data.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_f_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_f_dist.tests"></a></span><a class="link" href="nc_f_dist.html#math_toolkit.dist_ref.dists.nc_f_dist.tests">Tests</a>
|
||||
</h5>
|
||||
<p>
|
||||
Since this distribution is implemented by adapting another distribution,
|
||||
the tests consist of basic sanity checks computed by the <a href="http://www.r-project.org/" target="_top">R-2.5.1
|
||||
Math library statistical package</a> and its pbeta and dbeta functions.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_f_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_f_dist.implementation"></a></span><a class="link" href="nc_f_dist.html#math_toolkit.dist_ref.dists.nc_f_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table <span class="emphasis"><em>v1</em></span> and <span class="emphasis"><em>v2</em></span>
|
||||
are the first and second degrees of freedom parameters of the distribution,
|
||||
λ
|
||||
is the non-centrality parameter, <span class="emphasis"><em>x</em></span> is the random variate,
|
||||
<span class="emphasis"><em>p</em></span> is the probability, and <span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Implemented in terms of the non-central beta PDF using the relation:
|
||||
</p>
|
||||
<p>
|
||||
f(x;v1,v2;λ) = (v1/v2) / ((1+y)*(1+y)) * g(y/(1+y);v1/2,v2/2;λ)
|
||||
</p>
|
||||
<p>
|
||||
where g(x; a, b; λ) is the non central beta PDF, and:
|
||||
</p>
|
||||
<p>
|
||||
y = x * v1 / v2
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation:
|
||||
</p>
|
||||
<p>
|
||||
p = B<sub>y</sub>(v1/2, v2/2; λ)
|
||||
</p>
|
||||
<p>
|
||||
where B<sub>x</sub>(a, b; λ) is the noncentral beta distribution CDF and
|
||||
</p>
|
||||
<p>
|
||||
y = x * v1 / v2
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation:
|
||||
</p>
|
||||
<p>
|
||||
q = 1 - B<sub>y</sub>(v1/2, v2/2; λ)
|
||||
</p>
|
||||
<p>
|
||||
where 1 - B<sub>x</sub>(a, b; λ) is the complement of the noncentral beta
|
||||
distribution CDF and
|
||||
</p>
|
||||
<p>
|
||||
y = x * v1 / v2
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation:
|
||||
</p>
|
||||
<p>
|
||||
x = (bx / (1-bx)) * (v1 / v2)
|
||||
</p>
|
||||
<p>
|
||||
where
|
||||
</p>
|
||||
<p>
|
||||
bx = Q<sub>p</sub><sup>-1</sup>(v1/2, v2/2; λ)
|
||||
</p>
|
||||
<p>
|
||||
and
|
||||
</p>
|
||||
<p>
|
||||
Q<sub>p</sub><sup>-1</sup>(v1/2, v2/2; λ)
|
||||
</p>
|
||||
<p>
|
||||
is the noncentral beta quantile.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
<p>
|
||||
from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation:
|
||||
</p>
|
||||
<p>
|
||||
x = (bx / (1-bx)) * (v1 / v2)
|
||||
</p>
|
||||
<p>
|
||||
where
|
||||
</p>
|
||||
<p>
|
||||
bx = QC<sub>q</sub><sup>-1</sup>(v1/2, v2/2; λ)
|
||||
</p>
|
||||
<p>
|
||||
and
|
||||
</p>
|
||||
<p>
|
||||
QC<sub>q</sub><sup>-1</sup>(v1/2, v2/2; λ)
|
||||
</p>
|
||||
<p>
|
||||
is the noncentral beta quantile from the complement.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
v2 * (v1 + l) / (v1 * (v2 - 2))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
By numeric maximalisation of the PDF.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Refer to, <a href="http://mathworld.wolfram.com/NoncentralF-Distribution.html" target="_top">Weisstein,
|
||||
Eric W. "Noncentral F-Distribution." From MathWorld--A
|
||||
Wolfram Web Resource.</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Refer to, <a href="http://mathworld.wolfram.com/NoncentralF-Distribution.html" target="_top">Weisstein,
|
||||
Eric W. "Noncentral F-Distribution." From MathWorld--A
|
||||
Wolfram Web Resource.</a>, and to the <a href="http://reference.wolfram.com/mathematica/ref/NoncentralFRatioDistribution.html" target="_top">Mathematica
|
||||
documentation</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis and kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Refer to, <a href="http://mathworld.wolfram.com/NoncentralF-Distribution.html" target="_top">Weisstein,
|
||||
Eric W. "Noncentral F-Distribution." From MathWorld--A
|
||||
Wolfram Web Resource.</a>, and to the <a href="http://reference.wolfram.com/mathematica/ref/NoncentralFRatioDistribution.html" target="_top">Mathematica
|
||||
documentation</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<p>
|
||||
Some analytic properties of noncentral distributions (particularly unimodality,
|
||||
and monotonicity of their modes) are surveyed and summarized by:
|
||||
</p>
|
||||
<p>
|
||||
Andrea van Aubel & Wolfgang Gawronski, Applied Mathematics and Computation,
|
||||
141 (2003) 3-12.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="nc_chi_squared_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="nc_t_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,566 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Noncentral T Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="nc_f_dist.html" title="Noncentral F Distribution">
|
||||
<link rel="next" href="normal_dist.html" title="Normal (Gaussian) Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="nc_f_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="normal_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.nc_t_dist"></a><a class="link" href="nc_t_dist.html" title="Noncentral T Distribution">Noncentral T
|
||||
Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">non_central_t</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">non_central_t_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">non_central_t_distribution</span><span class="special"><></span> <span class="identifier">non_central_t</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">non_central_t_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Constructor:</span>
|
||||
<span class="identifier">non_central_t_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">delta</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// Accessor to degrees_of_freedom parameter v:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Accessor to non-centrality parameter delta:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">non_centrality</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The noncentral T distribution is a generalization of the <a class="link" href="students_t_dist.html" title="Students t Distribution">Students
|
||||
t Distribution</a>. Let X have a normal distribution with mean δ and variance
|
||||
1, and let ν S<sup>2</sup> have a chi-squared distribution with degrees of freedom ν.
|
||||
Assume that X and S<sup>2</sup> are independent. The distribution of t<sub>ν</sub>(δ)=X/S is called
|
||||
a noncentral t distribution with degrees of freedom ν and noncentrality parameter
|
||||
δ.
|
||||
</p>
|
||||
<p>
|
||||
This gives the following PDF:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_t_ref1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
where <sub>1</sub>F<sub>1</sub>(a;b;x) is a confluent hypergeometric function.
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates how the distribution changes for different
|
||||
values of ν and δ:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/nc_t_pdf.svg" align="middle"></span>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/nc_t_cdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_t_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_t_dist.member_functions"></a></span><a class="link" href="nc_t_dist.html#math_toolkit.dist_ref.dists.nc_t_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">non_central_t_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">delta</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a non-central t distribution with degrees of freedom parameter
|
||||
<span class="emphasis"><em>v</em></span> and non-centrality parameter <span class="emphasis"><em>delta</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Requires <span class="emphasis"><em>v</em></span> > 0 (including positive infinity) and
|
||||
finite <span class="emphasis"><em>delta</em></span>, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>v</em></span> from which this object was
|
||||
constructed.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">non_centrality</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the non-centrality parameter <span class="emphasis"><em>delta</em></span> from which
|
||||
this object was constructed.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_t_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_t_dist.non_member_accessors"></a></span><a class="link" href="nc_t_dist.html#math_toolkit.dist_ref.dists.nc_t_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [-∞, +∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_t_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_t_dist.accuracy"></a></span><a class="link" href="nc_t_dist.html#math_toolkit.dist_ref.dists.nc_t_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The following table shows the peak errors (in units of <a href="http://en.wikipedia.org/wiki/Machine_epsilon" target="_top">epsilon</a>)
|
||||
found on various platforms with various floating-point types. Unless otherwise
|
||||
specified, any floating-point type that is narrower than the one shown
|
||||
will have <a class="link" href="../../relative_error.html#math_toolkit.relative_error.zero_error">effectively
|
||||
zero error</a>.
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="math_toolkit.dist_ref.dists.nc_t_dist.table_non_central_t_CDF"></a><p class="title"><b>Table 5.8. Error rates for non central t CDF</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Error rates for non central t CDF">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Microsoft Visual C++ version 12.0<br> Win32<br> double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
GNU C++ version 5.1.0<br> linux<br> double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
GNU C++ version 5.1.0<br> linux<br> long double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Sun compiler version 0x5130<br> Sun Solaris<br> long double
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central T
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 138ε (Mean = 31.5ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 0.796ε (Mean = 0.0691ε)</span><br>
|
||||
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max
|
||||
= 5.28e+15ε (Mean = 8.49e+14ε) <a class="link" href="../../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_non_central_t_CDF_Rmath_3_0_2_Non_Central_T">And
|
||||
other failures.</a>)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 141ε (Mean = 31.1ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 145ε (Mean = 30.2ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central T (small non-centrality)
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 3.61ε (Mean = 1.03ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Rmath
|
||||
3.0.2:</em></span> Max = 2.09e+03ε (Mean = 244ε))
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 7.86ε (Mean = 1.69ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 9.15ε (Mean = 2.25ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central T (large parameters)
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 286ε (Mean = 62.8ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 257ε (Mean = 72.1ε)</span><br> <br>
|
||||
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 2.46ε (Mean = 0.657ε))
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 5.26e+05ε (Mean = 1.48e+05ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 5.24e+05ε (Mean = 1.47e+05ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break"><div class="table">
|
||||
<a name="math_toolkit.dist_ref.dists.nc_t_dist.table_non_central_t_CDF_complement"></a><p class="title"><b>Table 5.9. Error rates for non central t CDF complement</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Error rates for non central t CDF complement">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Microsoft Visual C++ version 12.0<br> Win32<br> double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
GNU C++ version 5.1.0<br> linux<br> double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
GNU C++ version 5.1.0<br> linux<br> long double
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Sun compiler version 0x5130<br> Sun Solaris<br> long double
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central T
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 150ε (Mean = 32.3ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 0.707ε (Mean = 0.0497ε)</span><br>
|
||||
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max
|
||||
= 6.19e+15ε (Mean = 6.72e+14ε) <a class="link" href="../../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_non_central_t_CDF_complement_Rmath_3_0_2_Non_Central_T">And
|
||||
other failures.</a>)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 203ε (Mean = 31.8ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 340ε (Mean = 43.6ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central T (small non-centrality)
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 5.21ε (Mean = 1.43ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Rmath
|
||||
3.0.2:</em></span> Max = 1.87e+03ε (Mean = 263ε))
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 7.48ε (Mean = 1.86ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 10.9ε (Mean = 2.43ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Non Central T (large parameters)
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 227ε (Mean = 50.4ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 478ε (Mean = 96.3ε)</span><br> <br>
|
||||
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 2.24ε (Mean = 0.945ε))
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 9.79e+05ε (Mean = 1.97e+05ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">Max = 9.79e+05ε (Mean = 1.97e+05ε)</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break"><div class="caution"><table border="0" summary="Caution">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../../doc/src/images/caution.png"></td>
|
||||
<th align="left">Caution</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
The complexity of the current algorithm is dependent upon δ<sup>2</sup>: consequently
|
||||
the time taken to evaluate the CDF increases rapidly for δ > 500, likewise
|
||||
the accuracy decreases rapidly for very large δ.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
Accuracy for the quantile and PDF functions should be broadly similar.
|
||||
The <span class="emphasis"><em>mode</em></span> is determined numerically and cannot in principal
|
||||
be more accurate than the square root of floating-point type FPT epsilon,
|
||||
accessed using <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">epsilon</span><span class="special"><</span><span class="identifier">FPT</span><span class="special">>()</span></code>.
|
||||
For 64-bit <code class="computeroutput"><span class="keyword">double</span></code>, epsilon
|
||||
is about 1e-16, so the fractional accuracy is limited to 1e-8.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_t_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_t_dist.tests"></a></span><a class="link" href="nc_t_dist.html#math_toolkit.dist_ref.dists.nc_t_dist.tests">Tests</a>
|
||||
</h5>
|
||||
<p>
|
||||
There are two sets of tests of this distribution:
|
||||
</p>
|
||||
<p>
|
||||
Basic sanity checks compare this implementation to the test values given
|
||||
in "Computing discrete mixtures of continuous distributions: noncentral
|
||||
chisquare, noncentral t and the distribution of the square of the sample
|
||||
multiple correlation coefficient." Denise Benton, K. Krishnamoorthy,
|
||||
Computational Statistics & Data Analysis 43 (2003) 249-267.
|
||||
</p>
|
||||
<p>
|
||||
Accuracy checks use test data computed with this implementation and arbitary
|
||||
precision interval arithmetic: this test data is believed to be accurate
|
||||
to at least 50 decimal places.
|
||||
</p>
|
||||
<p>
|
||||
The cases of large (or infinite) ν and/or large δ has received special treatment
|
||||
to avoid catastrophic loss of accuracy. New tests have been added to confirm
|
||||
the improvement achieved.
|
||||
</p>
|
||||
<p>
|
||||
From Boost 1.52, degrees of freedom ν can be +∞
|
||||
when the normal distribution
|
||||
located at δ
|
||||
(equivalent to the central Student's t distribution) is used
|
||||
in place for accuracy and speed.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.nc_t_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.nc_t_dist.implementation"></a></span><a class="link" href="nc_t_dist.html#math_toolkit.dist_ref.dists.nc_t_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
The CDF is computed using a modification of the method described in "Computing
|
||||
discrete mixtures of continuous distributions: noncentral chisquare, noncentral
|
||||
t and the distribution of the square of the sample multiple correlation
|
||||
coefficient." Denise Benton, K. Krishnamoorthy, Computational Statistics
|
||||
& Data Analysis 43 (2003) 249-267.
|
||||
</p>
|
||||
<p>
|
||||
This uses the following formula for the CDF:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_t_ref2.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
Where I<sub>x</sub>(a,b) is the incomplete beta function, and Φ(x) is the normal CDF
|
||||
at x.
|
||||
</p>
|
||||
<p>
|
||||
Iteration starts at the largest of the Poisson weighting terms (at i =
|
||||
δ<sup>2</sup> / 2) and then proceeds in both directions as per Benton and Krishnamoorthy's
|
||||
paper.
|
||||
</p>
|
||||
<p>
|
||||
Alternatively, by considering what happens when t = ∞, we have x = 1, and
|
||||
therefore I<sub>x</sub>(a,b) = 1 and:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_t_ref3.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
From this we can easily show that:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_t_ref4.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
and therefore we have a means to compute either the probability or its
|
||||
complement directly without the risk of cancellation error. The crossover
|
||||
criterion for choosing whether to calculate the CDF or its complement is
|
||||
the same as for the <a class="link" href="nc_beta_dist.html" title="Noncentral Beta Distribution">Noncentral
|
||||
Beta Distribution</a>.
|
||||
</p>
|
||||
<p>
|
||||
The PDF can be computed by a very similar method using:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/nc_t_ref5.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
Where I<sub>x</sub><sup>'</sup>(a,b) is the derivative of the incomplete beta function.
|
||||
</p>
|
||||
<p>
|
||||
For both the PDF and CDF we switch to approximating the distribution by
|
||||
a Student's t distribution centred on δ when ν is very large. The crossover
|
||||
location appears to be when δ/(4ν) < ε, this location was estimated by
|
||||
inspection of equation 2.6 in "A Comparison of Approximations To Percentiles
|
||||
of the Noncentral t-Distribution". H. Sahai and M. M. Ojeda, Revista
|
||||
Investigacion Operacional Vol 21, No 2, 2000, page 123.
|
||||
</p>
|
||||
<p>
|
||||
Equation 2.6 is a Fisher-Cornish expansion by Eeden and Johnson. The second
|
||||
term includes the ratio δ/(4ν), so when this term become negligible, this
|
||||
and following terms can be ignored, leaving just Student's t distribution
|
||||
centred on δ.
|
||||
</p>
|
||||
<p>
|
||||
This was also confirmed by experimental testing.
|
||||
</p>
|
||||
<p>
|
||||
See also
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
"Some Approximations to the Percentage Points of the Noncentral
|
||||
t-Distribution". C. van Eeden. International Statistical Review,
|
||||
29, 4-31.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
"Continuous Univariate Distributions". N.L. Johnson, S. Kotz
|
||||
and N. Balkrishnan. 1995. John Wiley and Sons New York.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
The quantile is calculated via the usual <a class="link" href="../../roots/roots_noderiv.html" title="Root Finding Without Derivatives">root-finding
|
||||
without derivatives</a> method with the initial guess taken as the quantile
|
||||
of a normal approximation to the noncentral T.
|
||||
</p>
|
||||
<p>
|
||||
There is no closed form for the mode, so this is computed via functional
|
||||
maximisation of the PDF.
|
||||
</p>
|
||||
<p>
|
||||
The remaining functions (mean, variance etc) are implemented using the
|
||||
formulas given in Weisstein, Eric W. "Noncentral Student's t-Distribution."
|
||||
From MathWorld--A Wolfram Web Resource. <a href="http://mathworld.wolfram.com/NoncentralStudentst-Distribution.html" target="_top">http://mathworld.wolfram.com/NoncentralStudentst-Distribution.html</a>
|
||||
and in the <a href="http://reference.wolfram.com/mathematica/ref/NoncentralStudentTDistribution.html" target="_top">Mathematica
|
||||
documentation</a>.
|
||||
</p>
|
||||
<p>
|
||||
Some analytic properties of noncentral distributions (particularly unimodality,
|
||||
and monotonicity of their modes) are surveyed and summarized by:
|
||||
</p>
|
||||
<p>
|
||||
Andrea van Aubel & Wolfgang Gawronski, Applied Mathematics and Computation,
|
||||
141 (2003) 3-12.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="nc_f_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="normal_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,883 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Negative Binomial Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="lognormal_dist.html" title="Log Normal Distribution">
|
||||
<link rel="next" href="nc_beta_dist.html" title="Noncentral Beta Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="lognormal_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="nc_beta_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.negative_binomial_dist"></a><a class="link" href="negative_binomial_dist.html" title="Negative Binomial Distribution">Negative
|
||||
Binomial Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">negative_binomial</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">negative_binomial_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">negative_binomial_distribution</span><span class="special"><></span> <span class="identifier">negative_binomial</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">negative_binomial_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
<span class="comment">// Constructor from successes and success_fraction:</span>
|
||||
<span class="identifier">negative_binomial_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">r</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// Parameter accessors:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">success_fraction</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Bounds on success fraction:</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_lower_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">trials</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// alpha</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_upper_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">trials</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// alpha</span>
|
||||
|
||||
<span class="comment">// Estimate min/max number of trials:</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_minimum_number_of_trials</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">k</span><span class="special">,</span> <span class="comment">// Number of failures.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// Success fraction.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// Probability threshold alpha.</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_maximum_number_of_trials</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">k</span><span class="special">,</span> <span class="comment">// Number of failures.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// Success fraction.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// Probability threshold alpha.</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The class type <code class="computeroutput"><span class="identifier">negative_binomial_distribution</span></code>
|
||||
represents a <a href="http://en.wikipedia.org/wiki/Negative_binomial_distribution" target="_top">negative_binomial
|
||||
distribution</a>: it is used when there are exactly two mutually exclusive
|
||||
outcomes of a <a href="http://en.wikipedia.org/wiki/Bernoulli_trial" target="_top">Bernoulli
|
||||
trial</a>: these outcomes are labelled "success" and "failure".
|
||||
</p>
|
||||
<p>
|
||||
For k + r Bernoulli trials each with success fraction p, the negative_binomial
|
||||
distribution gives the probability of observing k failures and r successes
|
||||
with success on the last trial. The negative_binomial distribution assumes
|
||||
that success_fraction p is fixed for all (k + r) trials.
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
The random variable for the negative binomial distribution is the number
|
||||
of trials, (the number of successes is a fixed property of the distribution)
|
||||
whereas for the binomial, the random variable is the number of successes,
|
||||
for a fixed number of trials.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
It has the PDF:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/neg_binomial_ref.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrate how the PDF varies as the success fraction
|
||||
<span class="emphasis"><em>p</em></span> changes:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/negative_binomial_pdf_1.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
Alternatively, this graph shows how the shape of the PDF varies as the
|
||||
number of successes changes:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/negative_binomial_pdf_2.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.negative_binomial_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.negative_binomial_dist.related_distributions"></a></span><a class="link" href="negative_binomial_dist.html#math_toolkit.dist_ref.dists.negative_binomial_dist.related_distributions">Related
|
||||
Distributions</a>
|
||||
</h5>
|
||||
<p>
|
||||
The name negative binomial distribution is reserved by some to the case
|
||||
where the successes parameter r is an integer. This integer version is
|
||||
also called the <a href="http://mathworld.wolfram.com/PascalDistribution.html" target="_top">Pascal
|
||||
distribution</a>.
|
||||
</p>
|
||||
<p>
|
||||
This implementation uses real numbers for the computation throughout (because
|
||||
it uses the <span class="bold"><strong>real-valued</strong></span> incomplete beta
|
||||
function family of functions). This real-valued version is also called
|
||||
the Polya Distribution.
|
||||
</p>
|
||||
<p>
|
||||
The Poisson distribution is a generalization of the Pascal distribution,
|
||||
where the success parameter r is an integer: to obtain the Pascal distribution
|
||||
you must ensure that an integer value is provided for r, and take integer
|
||||
values (floor or ceiling) from functions that return a number of successes.
|
||||
</p>
|
||||
<p>
|
||||
For large values of r (successes), the negative binomial distribution converges
|
||||
to the Poisson distribution.
|
||||
</p>
|
||||
<p>
|
||||
The geometric distribution is a special case where the successes parameter
|
||||
r = 1, so only a first and only success is required. geometric(p) = negative_binomial(1,
|
||||
p).
|
||||
</p>
|
||||
<p>
|
||||
The Poisson distribution is a special case for large successes
|
||||
</p>
|
||||
<p>
|
||||
poisson(λ) = lim <sub>r → ∞</sub>   negative_binomial(r, r / (λ + r)))
|
||||
</p>
|
||||
<div class="caution"><table border="0" summary="Caution">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../../doc/src/images/caution.png"></td>
|
||||
<th align="left">Caution</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
The Negative Binomial distribution is a discrete distribution: internally,
|
||||
functions like the <code class="computeroutput"><span class="identifier">cdf</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">pdf</span></code> are treated "as
|
||||
if" they are continuous functions, but in reality the results returned
|
||||
from these functions only have meaning if an integer value is provided
|
||||
for the random variate argument.
|
||||
</p>
|
||||
<p>
|
||||
The quantile function will by default return an integer result that has
|
||||
been <span class="emphasis"><em>rounded outwards</em></span>. That is to say lower quantiles
|
||||
(where the probability is less than 0.5) are rounded downward, and upper
|
||||
quantiles (where the probability is greater than 0.5) are rounded upwards.
|
||||
This behaviour ensures that if an X% quantile is requested, then <span class="emphasis"><em>at
|
||||
least</em></span> the requested coverage will be present in the central
|
||||
region, and <span class="emphasis"><em>no more than</em></span> the requested coverage
|
||||
will be present in the tails.
|
||||
</p>
|
||||
<p>
|
||||
This behaviour can be changed so that the quantile functions are rounded
|
||||
differently, or even return a real-valued result using <a class="link" href="../../pol_overview.html" title="Policy Overview">Policies</a>.
|
||||
It is strongly recommended that you read the tutorial <a class="link" href="../../pol_tutorial/understand_dis_quant.html" title="Understanding Quantiles of Discrete Distributions">Understanding
|
||||
Quantiles of Discrete Distributions</a> before using the quantile
|
||||
function on the Negative Binomial distribution. The <a class="link" href="../../pol_ref/discrete_quant_ref.html" title="Discrete Quantile Policies">reference
|
||||
docs</a> describe how to change the rounding policy for these distributions.
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.negative_binomial_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.negative_binomial_dist.member_functions"></a></span><a class="link" href="negative_binomial_dist.html#math_toolkit.dist_ref.dists.negative_binomial_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.negative_binomial_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.negative_binomial_dist.construct"></a></span><a class="link" href="negative_binomial_dist.html#math_toolkit.dist_ref.dists.negative_binomial_dist.construct">Construct</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="identifier">negative_binomial_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">r</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructor: <span class="emphasis"><em>r</em></span> is the total number of successes,
|
||||
<span class="emphasis"><em>p</em></span> is the probability of success of a single trial.
|
||||
</p>
|
||||
<p>
|
||||
Requires: <code class="computeroutput"><span class="identifier">r</span> <span class="special">></span>
|
||||
<span class="number">0</span></code> and <code class="computeroutput"><span class="number">0</span>
|
||||
<span class="special"><=</span> <span class="identifier">p</span>
|
||||
<span class="special"><=</span> <span class="number">1</span></code>.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.negative_binomial_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.negative_binomial_dist.accessors"></a></span><a class="link" href="negative_binomial_dist.html#math_toolkit.dist_ref.dists.negative_binomial_dist.accessors">Accessors</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">success_fraction</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> <span class="comment">// successes / trials (0 <= p <= 1)</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>p</em></span> from which this distribution
|
||||
was constructed.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> <span class="comment">// required successes (r > 0)</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the parameter <span class="emphasis"><em>r</em></span> from which this distribution
|
||||
was constructed.
|
||||
</p>
|
||||
<p>
|
||||
The best method of calculation for the following functions is disputed:
|
||||
see <a class="link" href="binomial_dist.html" title="Binomial Distribution">Binomial
|
||||
Distribution</a> for more discussion.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.negative_binomial_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.negative_binomial_dist.lower_bound_on_parameter_p"></a></span><a class="link" href="negative_binomial_dist.html#math_toolkit.dist_ref.dists.negative_binomial_dist.lower_bound_on_parameter_p">Lower
|
||||
Bound on Parameter p</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_lower_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">failures</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">)</span> <span class="comment">// (0 <= alpha <= 1), 0.05 equivalent to 95% confidence.</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns a <span class="bold"><strong>lower bound</strong></span> on the success fraction:
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">failures</span></dt>
|
||||
<dd><p>
|
||||
The total number of failures before the <span class="emphasis"><em>r</em></span>th
|
||||
success.
|
||||
</p></dd>
|
||||
<dt><span class="term">successes</span></dt>
|
||||
<dd><p>
|
||||
The number of successes required.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The largest acceptable probability that the true value of the success
|
||||
fraction is <span class="bold"><strong>less than</strong></span> the value
|
||||
returned.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
For example, if you observe <span class="emphasis"><em>k</em></span> failures and <span class="emphasis"><em>r</em></span>
|
||||
successes from <span class="emphasis"><em>n</em></span> = k + r trials the best estimate
|
||||
for the success fraction is simply <span class="emphasis"><em>r/n</em></span>, but if you
|
||||
want to be 95% sure that the true value is <span class="bold"><strong>greater
|
||||
than</strong></span> some value, <span class="emphasis"><em>p<sub>min</sub></em></span>, then:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">p</span><sub>min</sub> <span class="special">=</span> <span class="identifier">negative_binomial_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">find_lower_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">failures</span><span class="special">,</span> <span class="identifier">successes</span><span class="special">,</span> <span class="number">0.05</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
<a class="link" href="../../stat_tut/weg/neg_binom_eg/neg_binom_conf.html" title="Calculating Confidence Limits on the Frequency of Occurrence for the Negative Binomial Distribution">See
|
||||
negative binomial confidence interval example.</a>
|
||||
</p>
|
||||
<p>
|
||||
This function uses the Clopper-Pearson method of computing the lower bound
|
||||
on the success fraction, whilst many texts refer to this method as giving
|
||||
an "exact" result in practice it produces an interval that guarantees
|
||||
<span class="emphasis"><em>at least</em></span> the coverage required, and may produce pessimistic
|
||||
estimates for some combinations of <span class="emphasis"><em>failures</em></span> and <span class="emphasis"><em>successes</em></span>.
|
||||
See:
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://www.ucs.louisiana.edu/~kxk4695/Discrete_new.pdf" target="_top">Yong
|
||||
Cai and K. Krishnamoorthy, A Simple Improved Inferential Method for Some
|
||||
Discrete Distributions. Computational statistics and data analysis, 2005,
|
||||
vol. 48, no3, 605-621</a>.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.negative_binomial_dist.h5"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.negative_binomial_dist.upper_bound_on_parameter_p"></a></span><a class="link" href="negative_binomial_dist.html#math_toolkit.dist_ref.dists.negative_binomial_dist.upper_bound_on_parameter_p">Upper
|
||||
Bound on Parameter p</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_upper_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">trials</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">successes</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">);</span> <span class="comment">// (0 <= alpha <= 1), 0.05 equivalent to 95% confidence.</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns an <span class="bold"><strong>upper bound</strong></span> on the success
|
||||
fraction:
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">trials</span></dt>
|
||||
<dd><p>
|
||||
The total number of trials conducted.
|
||||
</p></dd>
|
||||
<dt><span class="term">successes</span></dt>
|
||||
<dd><p>
|
||||
The number of successes that occurred.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The largest acceptable probability that the true value of the success
|
||||
fraction is <span class="bold"><strong>greater than</strong></span> the value
|
||||
returned.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
For example, if you observe <span class="emphasis"><em>k</em></span> successes from <span class="emphasis"><em>n</em></span>
|
||||
trials the best estimate for the success fraction is simply <span class="emphasis"><em>k/n</em></span>,
|
||||
but if you want to be 95% sure that the true value is <span class="bold"><strong>less
|
||||
than</strong></span> some value, <span class="emphasis"><em>p<sub>max</sub></em></span>, then:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">p</span><sub>max</sub> <span class="special">=</span> <span class="identifier">negative_binomial_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">find_upper_bound_on_p</span><span class="special">(</span>
|
||||
<span class="identifier">r</span><span class="special">,</span> <span class="identifier">k</span><span class="special">,</span> <span class="number">0.05</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
<a class="link" href="../../stat_tut/weg/neg_binom_eg/neg_binom_conf.html" title="Calculating Confidence Limits on the Frequency of Occurrence for the Negative Binomial Distribution">See
|
||||
negative binomial confidence interval example.</a>
|
||||
</p>
|
||||
<p>
|
||||
This function uses the Clopper-Pearson method of computing the lower bound
|
||||
on the success fraction, whilst many texts refer to this method as giving
|
||||
an "exact" result in practice it produces an interval that guarantees
|
||||
<span class="emphasis"><em>at least</em></span> the coverage required, and may produce pessimistic
|
||||
estimates for some combinations of <span class="emphasis"><em>failures</em></span> and <span class="emphasis"><em>successes</em></span>.
|
||||
See:
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://www.ucs.louisiana.edu/~kxk4695/Discrete_new.pdf" target="_top">Yong
|
||||
Cai and K. Krishnamoorthy, A Simple Improved Inferential Method for Some
|
||||
Discrete Distributions. Computational statistics and data analysis, 2005,
|
||||
vol. 48, no3, 605-621</a>.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.negative_binomial_dist.h6"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.negative_binomial_dist.estimating_number_of_trials_to_e"></a></span><a class="link" href="negative_binomial_dist.html#math_toolkit.dist_ref.dists.negative_binomial_dist.estimating_number_of_trials_to_e">Estimating
|
||||
Number of Trials to Ensure at Least a Certain Number of Failures</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_minimum_number_of_trials</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">k</span><span class="special">,</span> <span class="comment">// number of failures.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// success fraction.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">);</span> <span class="comment">// probability threshold (0.05 equivalent to 95%).</span>
|
||||
</pre>
|
||||
<p>
|
||||
This functions estimates the number of trials required to achieve a certain
|
||||
probability that <span class="bold"><strong>more than k failures will be observed</strong></span>.
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">k</span></dt>
|
||||
<dd><p>
|
||||
The target number of failures to be observed.
|
||||
</p></dd>
|
||||
<dt><span class="term">p</span></dt>
|
||||
<dd><p>
|
||||
The probability of <span class="emphasis"><em>success</em></span> for each trial.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The maximum acceptable risk that only k failures or fewer will be
|
||||
observed.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">negative_binomial_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">find_minimum_number_of_trials</span><span class="special">(</span><span class="number">10</span><span class="special">,</span> <span class="number">0.5</span><span class="special">,</span> <span class="number">0.05</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the smallest number of trials we must conduct to be 95% sure of
|
||||
seeing 10 failures that occur with frequency one half.
|
||||
</p>
|
||||
<p>
|
||||
<a class="link" href="../../stat_tut/weg/neg_binom_eg/neg_binom_size_eg.html" title="Estimating Sample Sizes for the Negative Binomial.">Worked
|
||||
Example.</a>
|
||||
</p>
|
||||
<p>
|
||||
This function uses numeric inversion of the negative binomial distribution
|
||||
to obtain the result: another interpretation of the result, is that it
|
||||
finds the number of trials (success+failures) that will lead to an <span class="emphasis"><em>alpha</em></span>
|
||||
probability of observing k failures or fewer.
|
||||
</p>
|
||||
<h6>
|
||||
<a name="math_toolkit.dist_ref.dists.negative_binomial_dist.h7"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.negative_binomial_dist.estimating_number_of_trials_to_0"></a></span><a class="link" href="negative_binomial_dist.html#math_toolkit.dist_ref.dists.negative_binomial_dist.estimating_number_of_trials_to_0">Estimating
|
||||
Number of Trials to Ensure a Maximum Number of Failures or Less</a>
|
||||
</h6>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_maximum_number_of_trials</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">k</span><span class="special">,</span> <span class="comment">// number of failures.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// success fraction.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">);</span> <span class="comment">// probability threshold (0.05 equivalent to 95%).</span>
|
||||
</pre>
|
||||
<p>
|
||||
This functions estimates the maximum number of trials we can conduct and
|
||||
achieve a certain probability that <span class="bold"><strong>k failures or
|
||||
fewer will be observed</strong></span>.
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">k</span></dt>
|
||||
<dd><p>
|
||||
The maximum number of failures to be observed.
|
||||
</p></dd>
|
||||
<dt><span class="term">p</span></dt>
|
||||
<dd><p>
|
||||
The probability of <span class="emphasis"><em>success</em></span> for each trial.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The maximum acceptable <span class="emphasis"><em>risk</em></span> that more than k
|
||||
failures will be observed.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">negative_binomial_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>::</span><span class="identifier">find_maximum_number_of_trials</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">1.0</span><span class="special">-</span><span class="number">1.0</span><span class="special">/</span><span class="number">1000000</span><span class="special">,</span> <span class="number">0.05</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the largest number of trials we can conduct and still be 95% sure
|
||||
of seeing no failures that occur with frequency one in one million.
|
||||
</p>
|
||||
<p>
|
||||
This function uses numeric inversion of the negative binomial distribution
|
||||
to obtain the result: another interpretation of the result, is that it
|
||||
finds the number of trials (success+failures) that will lead to an <span class="emphasis"><em>alpha</em></span>
|
||||
probability of observing more than k failures.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.negative_binomial_dist.h8"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.negative_binomial_dist.non_member_accessors"></a></span><a class="link" href="negative_binomial_dist.html#math_toolkit.dist_ref.dists.negative_binomial_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
However it's worth taking a moment to define what these actually mean in
|
||||
the context of this distribution:
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="math_toolkit.dist_ref.dists.negative_binomial_dist.meaning_of_the_non_member_access"></a><p class="title"><b>Table 5.3. Meaning of the non-member accessors.</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Meaning of the non-member accessors.">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Meaning
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density
|
||||
Function</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The probability of obtaining <span class="bold"><strong>exactly k
|
||||
failures</strong></span> from k+r trials with success fraction p.
|
||||
For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">pdf</span><span class="special">(</span><span class="identifier">negative_binomial</span><span class="special">(</span><span class="identifier">r</span><span class="special">,</span> <span class="identifier">p</span><span class="special">),</span> <span class="identifier">k</span><span class="special">)</span></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution
|
||||
Function</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The probability of obtaining <span class="bold"><strong>k failures
|
||||
or fewer</strong></span> from k+r trials with success fraction p and
|
||||
success on the last trial. For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">negative_binomial</span><span class="special">(</span><span class="identifier">r</span><span class="special">,</span> <span class="identifier">p</span><span class="special">),</span> <span class="identifier">k</span><span class="special">)</span></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.ccdf">Complement of
|
||||
the Cumulative Distribution Function</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The probability of obtaining <span class="bold"><strong>more than
|
||||
k failures</strong></span> from k+r trials with success fraction p
|
||||
and success on the last trial. For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">negative_binomial</span><span class="special">(</span><span class="identifier">r</span><span class="special">,</span> <span class="identifier">p</span><span class="special">),</span> <span class="identifier">k</span><span class="special">))</span></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The <span class="bold"><strong>greatest</strong></span> number of failures
|
||||
k expected to be observed from k+r trials with success fraction
|
||||
p, at probability P. Note that the value returned is a real-number,
|
||||
and not an integer. Depending on the use case you may want to
|
||||
take either the floor or ceiling of the real result. For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">negative_binomial</span><span class="special">(</span><span class="identifier">r</span><span class="special">,</span> <span class="identifier">p</span><span class="special">),</span> <span class="identifier">P</span><span class="special">)</span></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.quantile_c">Quantile
|
||||
from the complement of the probability</a>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The <span class="bold"><strong>smallest</strong></span> number of failures
|
||||
k expected to be observed from k+r trials with success fraction
|
||||
p, at probability P. Note that the value returned is a real-number,
|
||||
and not an integer. Depending on the use case you may want to
|
||||
take either the floor or ceiling of the real result. For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">negative_binomial</span><span class="special">(</span><span class="identifier">r</span><span class="special">,</span> <span class="identifier">p</span><span class="special">),</span> <span class="identifier">P</span><span class="special">))</span></pre>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break"><h5>
|
||||
<a name="math_toolkit.dist_ref.dists.negative_binomial_dist.h9"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.negative_binomial_dist.accuracy"></a></span><a class="link" href="negative_binomial_dist.html#math_toolkit.dist_ref.dists.negative_binomial_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
This distribution is implemented using the incomplete beta functions <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a> and <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>:
|
||||
please refer to these functions for information on accuracy.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.negative_binomial_dist.h10"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.negative_binomial_dist.implementation"></a></span><a class="link" href="negative_binomial_dist.html#math_toolkit.dist_ref.dists.negative_binomial_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table, <span class="emphasis"><em>p</em></span> is the probability that
|
||||
any one trial will be successful (the success fraction), <span class="emphasis"><em>r</em></span>
|
||||
is the number of successes, <span class="emphasis"><em>k</em></span> is the number of failures,
|
||||
<span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
pdf = exp(lgamma(r + k) - lgamma(r) - lgamma(k+1)) * pow(p, r)
|
||||
* pow((1-p), k)
|
||||
</p>
|
||||
<p>
|
||||
Implementation is in terms of <a class="link" href="../../sf_beta/beta_derivative.html" title="Derivative of the Incomplete Beta Function">ibeta_derivative</a>:
|
||||
</p>
|
||||
<p>
|
||||
(p/(r + k)) * ibeta_derivative(r, static_cast<RealType>(k+1),
|
||||
p) The function <a class="link" href="../../sf_beta/beta_derivative.html" title="Derivative of the Incomplete Beta Function">ibeta_derivative</a>
|
||||
is used here, since it has already been optimised for the lowest
|
||||
possible error - indeed this is really just a thin wrapper around
|
||||
part of the internals of the incomplete beta function.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation:
|
||||
</p>
|
||||
<p>
|
||||
cdf = I<sub>p</sub>(r, k+1) = ibeta(r, k+1, p)
|
||||
</p>
|
||||
<p>
|
||||
= ibeta(r, static_cast<RealType>(k+1), p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation:
|
||||
</p>
|
||||
<p>
|
||||
1 - cdf = I<sub>p</sub>(k+1, r)
|
||||
</p>
|
||||
<p>
|
||||
= ibetac(r, static_cast<RealType>(k+1), p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
ibeta_invb(r, p, P) - 1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
ibetac_invb(r, p, Q) -1)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">r</span><span class="special">(</span><span class="number">1</span><span class="special">-</span><span class="identifier">p</span><span class="special">)/</span><span class="identifier">p</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">r</span> <span class="special">(</span><span class="number">1</span><span class="special">-</span><span class="identifier">p</span><span class="special">)</span>
|
||||
<span class="special">/</span> <span class="identifier">p</span>
|
||||
<span class="special">*</span> <span class="identifier">p</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">floor</span><span class="special">((</span><span class="identifier">r</span><span class="special">-</span><span class="number">1</span><span class="special">)</span> <span class="special">*</span> <span class="special">(</span><span class="number">1</span> <span class="special">-</span> <span class="identifier">p</span><span class="special">)/</span><span class="identifier">p</span><span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">(</span><span class="number">2</span>
|
||||
<span class="special">-</span> <span class="identifier">p</span><span class="special">)</span> <span class="special">/</span>
|
||||
<span class="identifier">sqrt</span><span class="special">(</span><span class="identifier">r</span> <span class="special">*</span>
|
||||
<span class="special">(</span><span class="number">1</span>
|
||||
<span class="special">-</span> <span class="identifier">p</span><span class="special">))</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="number">6</span> <span class="special">/</span>
|
||||
<span class="identifier">r</span> <span class="special">+</span>
|
||||
<span class="special">(</span><span class="identifier">p</span>
|
||||
<span class="special">*</span> <span class="identifier">p</span><span class="special">)</span> <span class="special">/</span>
|
||||
<span class="identifier">r</span> <span class="special">*</span>
|
||||
<span class="special">(</span><span class="number">1</span>
|
||||
<span class="special">-</span> <span class="identifier">p</span>
|
||||
<span class="special">)</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="number">6</span> <span class="special">/</span>
|
||||
<span class="identifier">r</span> <span class="special">+</span>
|
||||
<span class="special">(</span><span class="identifier">p</span>
|
||||
<span class="special">*</span> <span class="identifier">p</span><span class="special">)</span> <span class="special">/</span>
|
||||
<span class="identifier">r</span> <span class="special">*</span>
|
||||
<span class="special">(</span><span class="number">1</span>
|
||||
<span class="special">-</span> <span class="identifier">p</span>
|
||||
<span class="special">)</span> <span class="special">-</span><span class="number">3</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
parameter estimation member functions
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">find_lower_bound_on_p</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
ibeta_inv(successes, failures + 1, alpha)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">find_upper_bound_on_p</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
ibetac_inv(successes, failures, alpha) plus see comments in code.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">find_minimum_number_of_trials</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
ibeta_inva(k + 1, p, alpha)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">find_maximum_number_of_trials</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
ibetac_inva(k + 1, p, alpha)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<p>
|
||||
Implementation notes:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
The real concept type (that deliberately lacks the Lanczos approximation),
|
||||
was found to take several minutes to evaluate some extreme test values,
|
||||
so the test has been disabled for this type.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Much greater speed, and perhaps greater accuracy, might be achieved
|
||||
for extreme values by using a normal approximation. This is NOT been
|
||||
tested or implemented.
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="lognormal_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="nc_beta_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,325 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Normal (Gaussian) Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="nc_t_dist.html" title="Noncentral T Distribution">
|
||||
<link rel="next" href="pareto.html" title="Pareto Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="nc_t_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="pareto.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.normal_dist"></a><a class="link" href="normal_dist.html" title="Normal (Gaussian) Distribution">Normal (Gaussian)
|
||||
Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">normal</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">normal_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">normal_distribution</span><span class="special"><></span> <span class="identifier">normal</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">normal_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
<span class="comment">// Construct:</span>
|
||||
<span class="identifier">normal_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">mean</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">sd</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
|
||||
<span class="comment">// Accessors:</span>
|
||||
<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">// location.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">standard_deviation</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// scale.</span>
|
||||
<span class="comment">// Synonyms, provided to allow generic use of find_location and find_scale.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<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="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The normal distribution is probably the most well known statistical distribution:
|
||||
it is also known as the Gaussian Distribution. A normal distribution with
|
||||
mean zero and standard deviation one is known as the <span class="emphasis"><em>Standard
|
||||
Normal Distribution</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Given mean μ  and standard deviation σ  it has the PDF:
|
||||
</p>
|
||||
<p>
|
||||
  <span class="inlinemediaobject"><img src="../../../../equations/normal_ref1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
The variation the PDF with its parameters is illustrated in the following
|
||||
graph:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/normal_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
The cumulative distribution function is given by
|
||||
</p>
|
||||
<p>
|
||||
  <span class="inlinemediaobject"><img src="../../../../equations/normal_cdf.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
and illustrated by this graph
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/normal_cdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.normal_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.normal_dist.member_functions"></a></span><a class="link" href="normal_dist.html#math_toolkit.dist_ref.dists.normal_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">normal_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">mean</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">sd</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a normal distribution with mean <span class="emphasis"><em>mean</em></span> and
|
||||
standard deviation <span class="emphasis"><em>sd</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Requires sd > 0, otherwise <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
is called.
|
||||
</p>
|
||||
<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>
|
||||
<span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
both return the <span class="emphasis"><em>mean</em></span> of this distribution.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">standard_deviation</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
both return the <span class="emphasis"><em>standard deviation</em></span> of this distribution.
|
||||
(Redundant location and scale function are provided to match other similar
|
||||
distributions, allowing the functions find_location and find_scale to be
|
||||
used generically).
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.normal_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.normal_dist.non_member_accessors"></a></span><a class="link" href="normal_dist.html#math_toolkit.dist_ref.dists.normal_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [-[max_value], +[min_value]]. However,
|
||||
the pdf of +∞ and -∞ = 0 is also supported, and cdf at -∞ = 0, cdf at +∞ = 1, and
|
||||
complement cdf -∞ = 1 and +∞ = 0, if RealType permits.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.normal_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.normal_dist.accuracy"></a></span><a class="link" href="normal_dist.html#math_toolkit.dist_ref.dists.normal_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The normal distribution is implemented in terms of the <a class="link" href="../../sf_erf/error_function.html" title="Error Functions">error
|
||||
function</a>, and as such should have very low error rates.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.normal_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.normal_dist.implementation"></a></span><a class="link" href="normal_dist.html#math_toolkit.dist_ref.dists.normal_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table <span class="emphasis"><em>m</em></span> is the mean of the distribution,
|
||||
and <span class="emphasis"><em>s</em></span> is its standard deviation.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = e<sup>-(x-m)<sup>2</sup>/(2s<sup>2</sup>)</sup> / (s * sqrt(2*pi))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: p = 0.5 * <a class="link" href="../../sf_erf/error_function.html" title="Error Functions">erfc</a>(-(x-m)/(s*sqrt(2)))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = 0.5 * <a class="link" href="../../sf_erf/error_function.html" title="Error Functions">erfc</a>((x-m)/(s*sqrt(2)))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = m - s * sqrt(2) * <a class="link" href="../../sf_erf/error_inv.html" title="Error Function Inverses">erfc_inv</a>(2*p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = m + s * sqrt(2) * <a class="link" href="../../sf_erf/error_inv.html" title="Error Function Inverses">erfc_inv</a>(2*p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean and standard deviation
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The same as <code class="computeroutput"><span class="identifier">dist</span><span class="special">.</span><span class="identifier">mean</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">dist</span><span class="special">.</span><span class="identifier">standard_deviation</span><span class="special">()</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The same as the mean.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
median
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The same as the mean.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
0
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
3
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
0
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="nc_t_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="pareto.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,350 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Pareto Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="normal_dist.html" title="Normal (Gaussian) Distribution">
|
||||
<link rel="next" href="poisson_dist.html" title="Poisson Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="normal_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="poisson_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.pareto"></a><a class="link" href="pareto.html" title="Pareto Distribution">Pareto Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">pareto</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">pareto_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">pareto_distribution</span><span class="special"><></span> <span class="identifier">pareto</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">pareto_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="comment">// Constructor:</span>
|
||||
<span class="identifier">pareto_distribution</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="identifier">RealType</span> <span class="identifier">shape</span> <span class="special">=</span> <span class="number">1</span><span class="special">)</span>
|
||||
<span class="comment">// Accessors:</span>
|
||||
<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="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/pareto_distribution" target="_top">Pareto
|
||||
distribution</a> is a continuous distribution with the <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability
|
||||
density function (pdf)</a>:
|
||||
</p>
|
||||
<p>
|
||||
f(x; α, β) = αβ<sup>α</sup> / x<sup>α+ 1</sup>
|
||||
</p>
|
||||
<p>
|
||||
For shape parameter α   > 0, and scale parameter β   > 0. If x < β  , the
|
||||
pdf is zero.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="http://mathworld.wolfram.com/ParetoDistribution.html" target="_top">Pareto
|
||||
distribution</a> often describes the larger compared to the smaller.
|
||||
A classic example is that 80% of the wealth is owned by 20% of the population.
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates how the PDF varies with the scale parameter
|
||||
β:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/pareto_pdf1.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
And this graph illustrates how the PDF varies with the shape parameter
|
||||
α:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/pareto_pdf2.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.pareto.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.pareto.related_distributions"></a></span><a class="link" href="pareto.html#math_toolkit.dist_ref.dists.pareto.related_distributions">Related
|
||||
distributions</a>
|
||||
</h5>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.pareto.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.pareto.member_functions"></a></span><a class="link" href="pareto.html#math_toolkit.dist_ref.dists.pareto.member_functions">Member Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">pareto_distribution</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="identifier">RealType</span> <span class="identifier">shape</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a <a href="http://en.wikipedia.org/wiki/pareto_distribution" target="_top">pareto
|
||||
distribution</a> with shape <span class="emphasis"><em>shape</em></span> and scale <span class="emphasis"><em>scale</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Requires that the <span class="emphasis"><em>shape</em></span> and <span class="emphasis"><em>scale</em></span>
|
||||
parameters are both greater than zero, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>scale</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>shape</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.pareto.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.pareto.non_member_accessors"></a></span><a class="link" href="pareto.html#math_toolkit.dist_ref.dists.pareto.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The supported domain of the random variable is [scale, ∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.pareto.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.pareto.accuracy"></a></span><a class="link" href="pareto.html#math_toolkit.dist_ref.dists.pareto.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The Pareto distribution is implemented in terms of the standard library
|
||||
<code class="computeroutput"><span class="identifier">exp</span></code> functions plus <a class="link" href="../../powers/expm1.html" title="expm1">expm1</a> and so should have very
|
||||
small errors, usually only a few epsilon.
|
||||
</p>
|
||||
<p>
|
||||
If probability is near to unity (or the complement of a probability near
|
||||
zero) see also <a class="link" href="../../stat_tut/overview/complements.html#why_complements">why complements?</a>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.pareto.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.pareto.implementation"></a></span><a class="link" href="pareto.html#math_toolkit.dist_ref.dists.pareto.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table α   is the shape parameter of the distribution, and
|
||||
β   is its scale parameter, <span class="emphasis"><em>x</em></span> is the random variate,
|
||||
<span class="emphasis"><em>p</em></span> is the probability and its complement <span class="emphasis"><em>q
|
||||
= 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf p = αβ<sup>α</sup>/x<sup>α +1</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: cdf p = 1 - (β   / x)<sup>α</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = 1 - p = -(β   / x)<sup>α</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = β / (1 - p)<sup>1/α</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = β / (q)<sup>1/α</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
αβ / (β - 1)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
βα<sup>2</sup> / (β - 1)<sup>2</sup> (β - 2)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
α
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Refer to <a href="http://mathworld.wolfram.com/ParetoDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Pareto Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Refer to <a href="http://mathworld.wolfram.com/ParetoDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Pareto Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Refer to <a href="http://mathworld.wolfram.com/ParetoDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "pareto Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.pareto.h5"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.pareto.references"></a></span><a class="link" href="pareto.html#math_toolkit.dist_ref.dists.pareto.references">References</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://en.wikipedia.org/wiki/pareto_distribution" target="_top">Pareto
|
||||
Distribution</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://mathworld.wolfram.com/paretoDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Pareto Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Handbook of Statistical Distributions with Applications, K Krishnamoorthy,
|
||||
ISBN 1-58488-635-8, Chapter 23, pp 257 - 267. (Note the meaning of
|
||||
a and b is reversed in Wolfram and Krishnamoorthy).
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="normal_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="poisson_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,330 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Poisson Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="pareto.html" title="Pareto Distribution">
|
||||
<link rel="next" href="rayleigh.html" title="Rayleigh Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="pareto.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="rayleigh.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.poisson_dist"></a><a class="link" href="poisson_dist.html" title="Poisson Distribution">Poisson Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">poisson</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">poisson_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">poisson_distribution</span><span class="special"><></span> <span class="identifier">poisson</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">poisson_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">poisson_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="comment">// Constructor.</span>
|
||||
<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">// Accessor.</span>
|
||||
<span class="special">}</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces boost::math</span>
|
||||
</pre>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Poisson_distribution" target="_top">Poisson
|
||||
distribution</a> is a well-known statistical discrete distribution.
|
||||
It expresses the probability of a number of events (or failures, arrivals,
|
||||
occurrences ...) occurring in a fixed period of time, provided these events
|
||||
occur with a known mean rate λ  
|
||||
(events/time), and are independent of the
|
||||
time since the last event.
|
||||
</p>
|
||||
<p>
|
||||
The distribution was discovered by Simé on-Denis Poisson (1781 to 1840).
|
||||
</p>
|
||||
<p>
|
||||
It has the Probability Mass Function:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/poisson_ref1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
for k events, with an expected number of events λ.
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates how the PDF varies with the parameter λ:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/poisson_pdf_1.svg" align="middle"></span>
|
||||
</p>
|
||||
<div class="caution"><table border="0" summary="Caution">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../../doc/src/images/caution.png"></td>
|
||||
<th align="left">Caution</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
The Poisson distribution is a discrete distribution: internally, functions
|
||||
like the <code class="computeroutput"><span class="identifier">cdf</span></code> and <code class="computeroutput"><span class="identifier">pdf</span></code> are treated "as if" they
|
||||
are continuous functions, but in reality the results returned from these
|
||||
functions only have meaning if an integer value is provided for the random
|
||||
variate argument.
|
||||
</p>
|
||||
<p>
|
||||
The quantile function will by default return an integer result that has
|
||||
been <span class="emphasis"><em>rounded outwards</em></span>. That is to say lower quantiles
|
||||
(where the probability is less than 0.5) are rounded downward, and upper
|
||||
quantiles (where the probability is greater than 0.5) are rounded upwards.
|
||||
This behaviour ensures that if an X% quantile is requested, then <span class="emphasis"><em>at
|
||||
least</em></span> the requested coverage will be present in the central
|
||||
region, and <span class="emphasis"><em>no more than</em></span> the requested coverage
|
||||
will be present in the tails.
|
||||
</p>
|
||||
<p>
|
||||
This behaviour can be changed so that the quantile functions are rounded
|
||||
differently, or even return a real-valued result using <a class="link" href="../../pol_overview.html" title="Policy Overview">Policies</a>.
|
||||
It is strongly recommended that you read the tutorial <a class="link" href="../../pol_tutorial/understand_dis_quant.html" title="Understanding Quantiles of Discrete Distributions">Understanding
|
||||
Quantiles of Discrete Distributions</a> before using the quantile
|
||||
function on the Poisson distribution. The <a class="link" href="../../pol_ref/discrete_quant_ref.html" title="Discrete Quantile Policies">reference
|
||||
docs</a> describe how to change the rounding policy for these distributions.
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.poisson_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.poisson_dist.member_functions"></a></span><a class="link" href="poisson_dist.html#math_toolkit.dist_ref.dists.poisson_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">poisson_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>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a poisson distribution with mean <span class="emphasis"><em>mean</em></span>.
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>mean</em></span> of this distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.poisson_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.poisson_dist.non_member_accessors"></a></span><a class="link" href="poisson_dist.html#math_toolkit.dist_ref.dists.poisson_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [0, ∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.poisson_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.poisson_dist.accuracy"></a></span><a class="link" href="poisson_dist.html#math_toolkit.dist_ref.dists.poisson_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The Poisson distribution is implemented in terms of the incomplete gamma
|
||||
functions <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_p</a> and
|
||||
<a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_q</a> and as such
|
||||
should have low error rates: but refer to the documentation of those functions
|
||||
for more information. The quantile and its complement use the inverse gamma
|
||||
functions and are therefore probably slightly less accurate: this is because
|
||||
the inverse gamma functions are implemented using an iterative method with
|
||||
a lower tolerance to avoid excessive computation.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.poisson_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.poisson_dist.implementation"></a></span><a class="link" href="poisson_dist.html#math_toolkit.dist_ref.dists.poisson_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table λ   is the mean of the distribution, <span class="emphasis"><em>k</em></span>
|
||||
is the random variable, <span class="emphasis"><em>p</em></span> is the probability and
|
||||
<span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = e<sup>-λ</sup> λ<sup>k</sup> / k!
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: p = Γ(k+1, λ) / k! = <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_q</a>(k+1,
|
||||
λ)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_p</a>(k+1,
|
||||
λ)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: k = <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_q_inva</a>(λ,
|
||||
p) - 1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: k = <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_p_inva</a>(λ,
|
||||
q) - 1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
λ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
floor (λ) or ⌊λ⌋
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1/√λ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
3 + 1/λ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1/λ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="pareto.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="rayleigh.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,347 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Rayleigh Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="poisson_dist.html" title="Poisson Distribution">
|
||||
<link rel="next" href="skew_normal_dist.html" title="Skew Normal Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="poisson_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="skew_normal_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.rayleigh"></a><a class="link" href="rayleigh.html" title="Rayleigh Distribution">Rayleigh Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">rayleigh</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">rayleigh_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">rayleigh_distribution</span><span class="special"><></span> <span class="identifier">rayleigh</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">rayleigh_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
<span class="comment">// Construct:</span>
|
||||
<span class="identifier">rayleigh_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">sigma</span> <span class="special">=</span> <span class="number">1</span><span class="special">)</span>
|
||||
<span class="comment">// Accessors:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">sigma</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Rayleigh_distribution" target="_top">Rayleigh
|
||||
distribution</a> is a continuous distribution with the <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability
|
||||
density function</a>:
|
||||
</p>
|
||||
<p>
|
||||
f(x; sigma) = x * exp(-x<sup>2</sup>/2 σ<sup>2</sup>) / σ<sup>2</sup>
|
||||
</p>
|
||||
<p>
|
||||
For sigma parameter σ   > 0, and x > 0.
|
||||
</p>
|
||||
<p>
|
||||
The Rayleigh distribution is often used where two orthogonal components
|
||||
have an absolute value, for example, wind velocity and direction may be
|
||||
combined to yield a wind speed, or real and imaginary components may have
|
||||
absolute values that are Rayleigh distributed.
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates how the Probability density Function(pdf)
|
||||
varies with the shape parameter σ:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/rayleigh_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
and the Cumulative Distribution Function (cdf)
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/rayleigh_cdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.rayleigh.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.rayleigh.related_distributions"></a></span><a class="link" href="rayleigh.html#math_toolkit.dist_ref.dists.rayleigh.related_distributions">Related
|
||||
distributions</a>
|
||||
</h5>
|
||||
<p>
|
||||
The absolute value of two independent normal distributions X and Y, √ (X<sup>2</sup> +
|
||||
Y<sup>2</sup>) is a Rayleigh distribution.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Chi_distribution" target="_top">Chi</a>,
|
||||
<a href="http://en.wikipedia.org/wiki/Rice_distribution" target="_top">Rice</a>
|
||||
and <a href="http://en.wikipedia.org/wiki/Weibull_distribution" target="_top">Weibull</a>
|
||||
distributions are generalizations of the <a href="http://en.wikipedia.org/wiki/Rayleigh_distribution" target="_top">Rayleigh
|
||||
distribution</a>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.rayleigh.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.rayleigh.member_functions"></a></span><a class="link" href="rayleigh.html#math_toolkit.dist_ref.dists.rayleigh.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">rayleigh_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">sigma</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a <a href="http://en.wikipedia.org/wiki/Rayleigh_distribution" target="_top">Rayleigh
|
||||
distribution</a> with σ <span class="emphasis"><em>sigma</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Requires that the σ parameter is greater than zero, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">sigma</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>sigma</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.rayleigh.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.rayleigh.non_member_accessors"></a></span><a class="link" href="rayleigh.html#math_toolkit.dist_ref.dists.rayleigh.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [0, max_value].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.rayleigh.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.rayleigh.accuracy"></a></span><a class="link" href="rayleigh.html#math_toolkit.dist_ref.dists.rayleigh.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The Rayleigh distribution is implemented in terms of the standard library
|
||||
<code class="computeroutput"><span class="identifier">sqrt</span></code> and <code class="computeroutput"><span class="identifier">exp</span></code> and as such should have very low
|
||||
error rates. Some constants such as skewness and kurtosis were calculated
|
||||
using NTL RR type with 150-bit accuracy, about 50 decimal digits.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.rayleigh.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.rayleigh.implementation"></a></span><a class="link" href="rayleigh.html#math_toolkit.dist_ref.dists.rayleigh.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table σ   is the sigma parameter of the distribution, <span class="emphasis"><em>x</em></span>
|
||||
is the random variate, <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q
|
||||
= 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = x * exp(-x<sup>2</sup>)/2 σ<sup>2</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: p = 1 - exp(-x<sup>2</sup>/2) σ<sup>2</sup>   = -<a class="link" href="../../powers/expm1.html" title="expm1">expm1</a>(-x<sup>2</sup>/2)
|
||||
σ<sup>2</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = exp(-x<sup>2</sup>/ 2) * σ<sup>2</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = sqrt(-2 * σ <sup>2</sup>) * log(1 - p)) = sqrt(-2
|
||||
* σ <sup>2</sup>) * <a class="link" href="../../powers/log1p.html" title="log1p">log1p</a>(-p))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = sqrt(-2 * σ <sup>2</sup>) * log(q))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
σ * sqrt(π/2)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
σ<sup>2</sup> * (4 - π/2)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
σ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Constant from <a href="http://mathworld.wolfram.com/RayleighDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Weibull Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Constant from <a href="http://mathworld.wolfram.com/RayleighDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Weibull Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Constant from <a href="http://mathworld.wolfram.com/RayleighDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Weibull Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.rayleigh.h5"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.rayleigh.references"></a></span><a class="link" href="rayleigh.html#math_toolkit.dist_ref.dists.rayleigh.references">References</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://en.wikipedia.org/wiki/Rayleigh_distribution" target="_top">http://en.wikipedia.org/wiki/Rayleigh_distribution</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://mathworld.wolfram.com/RayleighDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Rayleigh Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="poisson_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="skew_normal_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,498 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Skew Normal Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="rayleigh.html" title="Rayleigh Distribution">
|
||||
<link rel="next" href="students_t_dist.html" title="Students t Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="rayleigh.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="students_t_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.skew_normal_dist"></a><a class="link" href="skew_normal_dist.html" title="Skew Normal Distribution">Skew
|
||||
Normal Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">skew_normal</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">skew_normal_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">skew_normal_distribution</span><span class="special"><></span> <span class="identifier">normal</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">skew_normal_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
<span class="comment">// Constructor:</span>
|
||||
<span class="identifier">skew_normal_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</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="identifier">RealType</span> <span class="identifier">shape</span> <span class="special">=</span> <span class="number">0</span><span class="special">);</span>
|
||||
<span class="comment">// Accessors:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// mean if normal.</span>
|
||||
<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">// width, standard deviation if normal.</span>
|
||||
<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">// The distribution is right skewed if shape > 0 and is left skewed if shape < 0.</span>
|
||||
<span class="comment">// The distribution is normal if shape is zero.</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The skew normal distribution is a variant of the most well known Gaussian
|
||||
statistical distribution.
|
||||
</p>
|
||||
<p>
|
||||
The skew normal distribution with shape zero resembles the <a href="http://en.wikipedia.org/wiki/Normal_distribution" target="_top">Normal
|
||||
Distribution</a>, hence the latter can be regarded as a special case
|
||||
of the more generic skew normal distribution.
|
||||
</p>
|
||||
<p>
|
||||
If the standard (mean = 0, scale = 1) normal distribution probability density
|
||||
function is
|
||||
</p>
|
||||
<p>
|
||||
    <span class="inlinemediaobject"><img src="../../../../equations/normal01_pdf.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
and the cumulative distribution function
|
||||
</p>
|
||||
<p>
|
||||
    <span class="inlinemediaobject"><img src="../../../../equations/normal01_cdf.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
then the <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">PDF</a>
|
||||
of the <a href="http://en.wikipedia.org/wiki/Skew_normal_distribution" target="_top">skew
|
||||
normal distribution</a> with shape parameter α, defined by O'Hagan and
|
||||
Leonhard (1976) is
|
||||
</p>
|
||||
<p>
|
||||
    <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_pdf0.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
Given <a href="http://en.wikipedia.org/wiki/Location_parameter" target="_top">location</a>
|
||||
ξ, <a href="http://en.wikipedia.org/wiki/Scale_parameter" target="_top">scale</a>
|
||||
ω, and <a href="http://en.wikipedia.org/wiki/Shape_parameter" target="_top">shape</a>
|
||||
α, it can be <a href="http://en.wikipedia.org/wiki/Skew_normal_distribution" target="_top">transformed</a>,
|
||||
to the form:
|
||||
</p>
|
||||
<p>
|
||||
    <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_pdf.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
and <a href="http://en.wikipedia.org/wiki/Cumulative_distribution_function" target="_top">CDF</a>:
|
||||
</p>
|
||||
<p>
|
||||
    <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_cdf.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
where <span class="emphasis"><em>T(h,a)</em></span> is Owen's T function, and <span class="emphasis"><em>Φ(x)</em></span>
|
||||
is the normal distribution.
|
||||
</p>
|
||||
<p>
|
||||
The variation the PDF and CDF with its parameters is illustrated in the
|
||||
following graphs:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/skew_normal_pdf.svg" align="middle"></span>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/skew_normal_cdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.skew_normal_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.member_functions"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">skew_normal_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</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="identifier">RealType</span> <span class="identifier">shape</span> <span class="special">=</span> <span class="number">0</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a skew_normal distribution with location ξ, scale ω and shape α.
|
||||
</p>
|
||||
<p>
|
||||
Requires scale > 0, otherwise <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
is called.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
returns the location ξ of this distribution,
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
returns the scale ω of this distribution,
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
returns the shape α of this distribution.
|
||||
</p>
|
||||
<p>
|
||||
(Location and scale function match other similar distributions, allowing
|
||||
the functions <code class="computeroutput"><span class="identifier">find_location</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">find_scale</span></code> to be used
|
||||
generically).
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
While the shape parameter may be chosen arbitrarily (finite), the resulting
|
||||
<span class="bold"><strong>skewness</strong></span> of the distribution is in fact
|
||||
limited to about (-1, 1); strictly, the interval is (-0.9952717, 0.9952717).
|
||||
</p>
|
||||
<p>
|
||||
A parameter δ is related to the shape α by δ = α / (1 + α²), and used in the expression
|
||||
for skewness <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_skewness.svg"></span>
|
||||
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.skew_normal_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.references"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.references">References</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://azzalini.stat.unipd.it/SN/" target="_top">Skew-Normal Probability
|
||||
Distribution</a> for many links and bibliography.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://azzalini.stat.unipd.it/SN/Intro/intro.html" target="_top">A very
|
||||
brief introduction to the skew-normal distribution</a> by Adelchi
|
||||
Azzalini (2005-11-2).
|
||||
</li>
|
||||
<li class="listitem">
|
||||
See a <a href="http://www.tri.org.au/azzalini.html" target="_top">skew-normal
|
||||
function animation</a>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.skew_normal_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.non_member_accessors"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is <span class="emphasis"><em>-[max_value], +[min_value]</em></span>.
|
||||
Infinite values are not supported.
|
||||
</p>
|
||||
<p>
|
||||
There are no <a href="http://en.wikipedia.org/wiki/Closed-form_expression" target="_top">closed-form
|
||||
expression</a> known for the mode and median, but these are computed
|
||||
for the
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
mode - by finding the maximum of the PDF.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
median - by computing <code class="computeroutput"><span class="identifier">quantile</span><span class="special">(</span><span class="number">1</span><span class="special">/</span><span class="number">2</span><span class="special">)</span></code>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
The maximum of the PDF is sought through searching the root of f'(x)=0.
|
||||
</p>
|
||||
<p>
|
||||
Both involve iterative methods that will have lower accuracy than other
|
||||
estimates.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.skew_normal_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.testing"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.testing">Testing</a>
|
||||
</h5>
|
||||
<p>
|
||||
<a href="http://www.r-project.org/" target="_top">The R Project for Statistical Computing</a>
|
||||
using library(sn) described at <a href="http://azzalini.stat.unipd.it/SN/" target="_top">Skew-Normal
|
||||
Probability Distribution</a>, and at <a href="http://cran.r-project.org/web/packages/sn/sn.pd" target="_top">R
|
||||
skew-normal(sn) package</a>.
|
||||
</p>
|
||||
<p>
|
||||
Package sn provides functions related to the skew-normal (SN) and the skew-t
|
||||
(ST) probability distributions, both for the univariate and for the the
|
||||
multivariate case, including regression models.
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://www.wolfram.com/products/mathematica/index.html" target="_top">Wolfram
|
||||
Mathematica</a> was also used to generate some more accurate spot test
|
||||
data.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.skew_normal_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.accuracy"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The skew_normal distribution with shape = zero is implemented as a special
|
||||
case, equivalent to the normal distribution in terms of the <a class="link" href="../../sf_erf/error_function.html" title="Error Functions">error
|
||||
function</a>, and therefore should have excellent accuracy.
|
||||
</p>
|
||||
<p>
|
||||
The PDF and mean, variance, skewness and kurtosis are also accurately evaluated
|
||||
using <a href="http://en.wikipedia.org/wiki/Analytical_expression" target="_top">analytical
|
||||
expressions</a>. The CDF requires <a href="http://en.wikipedia.org/wiki/Owen%27s_T_function" target="_top">Owen's
|
||||
T function</a> that is evaluated using a Boost C++ <a class="link" href="../../owens_t.html" title="Owen's T function">Owens
|
||||
T</a> implementation of the algorithms of M. Patefield and D. Tandy,
|
||||
Journal of Statistical Software, 5(5), 1-25 (2000); the complicated accuracy
|
||||
of this function is discussed in detail at <a class="link" href="../../owens_t.html" title="Owen's T function">Owens
|
||||
T</a>.
|
||||
</p>
|
||||
<p>
|
||||
The median and mode are calculated by iterative root finding, and both
|
||||
will be less accurate.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.skew_normal_dist.h5"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.implementation"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table, ξ is the location of the distribution, and ω is its
|
||||
scale, and α is its shape.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using: <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_pdf.svg"></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using: <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_cdf.svg"></span><br> where <span class="emphasis"><em>T(h,a)</em></span>
|
||||
is Owen's T function, and <span class="emphasis"><em>Φ(x)</em></span> is the normal
|
||||
distribution.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using: complement of normal distribution + 2 * Owens_t
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Maximum of the pdf is sought through searching the root of f'(x)=0
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
-quantile(SN(-location ξ, scale ω, -shapeα), p)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
location
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
location ξ
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
scale
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
scale ω
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
shape
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
shape α
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
median
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
quantile(1/2)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/skew_normal_mean.svg"></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Maximum of the pdf is sought through searching the root of f'(x)=0
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/skew_normal_variance.svg"></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/skew_normal_skewness.svg"></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess-3
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/skew_normal_kurt_ex.svg"></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="rayleigh.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="students_t_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,430 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Students t Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="skew_normal_dist.html" title="Skew Normal Distribution">
|
||||
<link rel="next" href="triangular_dist.html" title="Triangular Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="skew_normal_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="triangular_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.students_t_dist"></a><a class="link" href="students_t_dist.html" title="Students t Distribution">Students
|
||||
t Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">students_t</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">students_t_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">students_t_distribution</span><span class="special"><></span> <span class="identifier">students_t</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">students_t_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Construct:</span>
|
||||
<span class="identifier">students_t_distribution</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">RealType</span><span class="special">&</span> <span class="identifier">v</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// Accessor:</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// degrees of freedom estimation:</span>
|
||||
<span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_degrees_of_freedom</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">difference_from_mean</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">sd</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">hint</span> <span class="special">=</span> <span class="number">100</span><span class="special">);</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
A statistical distribution published by William Gosset in 1908. His employer,
|
||||
Guinness Breweries, required him to publish under a pseudonym (possibly
|
||||
to hide that they were using statistics), so he chose "Student".
|
||||
Given N independent measurements, let
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/students_t_dist.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
where <span class="emphasis"><em>M</em></span> is the population mean,<span class="emphasis"><em>μ</em></span>
|
||||
is the sample mean, and <span class="emphasis"><em>s</em></span> is the sample variance.
|
||||
</p>
|
||||
<p>
|
||||
Student's t-distribution is defined as the distribution of the random variable
|
||||
t which is - very loosely - the "best" that we can do not knowing
|
||||
the true standard deviation of the sample. It has the PDF:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../equations/students_t_ref1.svg"></span>
|
||||
</p>
|
||||
<p>
|
||||
The Student's t-distribution takes a single parameter: the number of degrees
|
||||
of freedom of the sample. When the degrees of freedom is <span class="emphasis"><em>one</em></span>
|
||||
then this distribution is the same as the Cauchy-distribution. As the number
|
||||
of degrees of freedom tends towards infinity, then this distribution approaches
|
||||
the normal-distribution. The following graph illustrates how the PDF varies
|
||||
with the degrees of freedom ν:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/students_t_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.students_t_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.students_t_dist.member_functions"></a></span><a class="link" href="students_t_dist.html#math_toolkit.dist_ref.dists.students_t_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">students_t_distribution</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">RealType</span><span class="special">&</span> <span class="identifier">v</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a Student's t-distribution with <span class="emphasis"><em>v</em></span> degrees
|
||||
of freedom.
|
||||
</p>
|
||||
<p>
|
||||
Requires <span class="emphasis"><em>v</em></span> > 0, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
Note that non-integral degrees of freedom are supported, and are meaningful
|
||||
under certain circumstances.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">degrees_of_freedom</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the number of degrees of freedom of this distribution.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_degrees_of_freedom</span><span class="special">(</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">difference_from_mean</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">sd</span><span class="special">,</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">hint</span> <span class="special">=</span> <span class="number">100</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the number of degrees of freedom required to observe a significant
|
||||
result in the Student's t test when the mean differs from the "true"
|
||||
mean by <span class="emphasis"><em>difference_from_mean</em></span>.
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">difference_from_mean</span></dt>
|
||||
<dd><p>
|
||||
The difference between the true mean and the sample mean that we
|
||||
wish to show is significant.
|
||||
</p></dd>
|
||||
<dt><span class="term">alpha</span></dt>
|
||||
<dd><p>
|
||||
The maximum acceptable probability of rejecting the null hypothesis
|
||||
when it is in fact true.
|
||||
</p></dd>
|
||||
<dt><span class="term">beta</span></dt>
|
||||
<dd><p>
|
||||
The maximum acceptable probability of failing to reject the null
|
||||
hypothesis when it is in fact false.
|
||||
</p></dd>
|
||||
<dt><span class="term">sd</span></dt>
|
||||
<dd><p>
|
||||
The sample standard deviation.
|
||||
</p></dd>
|
||||
<dt><span class="term">hint</span></dt>
|
||||
<dd><p>
|
||||
A hint for the location to start looking for the result, a good choice
|
||||
for this would be the sample size of a previous borderline Student's
|
||||
t test.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
Remember that for a two-sided test, you must divide alpha by two before
|
||||
calling this function.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
For more information on this function see the <a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc222.htm" target="_top">NIST
|
||||
Engineering Statistics Handbook</a>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.students_t_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.students_t_dist.non_member_accessors"></a></span><a class="link" href="students_t_dist.html#math_toolkit.dist_ref.dists.students_t_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [-∞, +∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.students_t_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.students_t_dist.examples"></a></span><a class="link" href="students_t_dist.html#math_toolkit.dist_ref.dists.students_t_dist.examples">Examples</a>
|
||||
</h5>
|
||||
<p>
|
||||
Various <a class="link" href="../../stat_tut/weg/st_eg.html" title="Student's t Distribution Examples">worked examples</a>
|
||||
are available illustrating the use of the Student's t distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.students_t_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.students_t_dist.accuracy"></a></span><a class="link" href="students_t_dist.html#math_toolkit.dist_ref.dists.students_t_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The normal distribution is implemented in terms of the <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">incomplete
|
||||
beta function</a> and <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">its
|
||||
inverses</a>, refer to accuracy data on those functions for more information.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.students_t_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.students_t_dist.implementation"></a></span><a class="link" href="students_t_dist.html#math_toolkit.dist_ref.dists.students_t_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table <span class="emphasis"><em>v</em></span> is the degrees of freedom
|
||||
of the distribution, <span class="emphasis"><em>t</em></span> is the random variate, <span class="emphasis"><em>p</em></span>
|
||||
is the probability and <span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = (v / (v + t<sup>2</sup>))<sup>(1+v)/2 </sup> / (sqrt(v) *
|
||||
<a class="link" href="../../sf_beta/beta_function.html" title="Beta">beta</a>(v/2,
|
||||
0.5))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relations:
|
||||
</p>
|
||||
<p>
|
||||
p = 1 - z <span class="emphasis"><em>iff t > 0</em></span>
|
||||
</p>
|
||||
<p>
|
||||
p = z <span class="emphasis"><em>otherwise</em></span>
|
||||
</p>
|
||||
<p>
|
||||
where z is given by:
|
||||
</p>
|
||||
<p>
|
||||
<a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>(v
|
||||
/ 2, 0.5, v / (v + t<sup>2</sup>)) / 2 <span class="emphasis"><em>iff v < 2t<sup>2</sup></em></span>
|
||||
</p>
|
||||
<p>
|
||||
<a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>(0.5,
|
||||
v / 2, t<sup>2 </sup> / (v + t<sup>2</sup>) / 2 <span class="emphasis"><em>otherwise</em></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = cdf(-t)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: t = sign(p - 0.5) * sqrt(v * y / x)
|
||||
</p>
|
||||
<p>
|
||||
where:
|
||||
</p>
|
||||
<p>
|
||||
x = <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_inv</a>(v
|
||||
/ 2, 0.5, 2 * min(p, q))
|
||||
</p>
|
||||
<p>
|
||||
y = 1 - x
|
||||
</p>
|
||||
<p>
|
||||
The quantities <span class="emphasis"><em>x</em></span> and <span class="emphasis"><em>y</em></span>
|
||||
are both returned by <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_inv</a>
|
||||
without the subtraction implied above.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: t = -quantile(q)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
0
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
0
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
if (v > 2) v / (v - 2) else NaN
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
if (v > 3) 0 else NaN
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
if (v > 4) 3 * (v - 2) / (v - 4) else NaN
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
if (v > 4) 6 / (df - 4) else NaN
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<p>
|
||||
If the moment index <span class="emphasis"><em>k</em></span> is less than <span class="emphasis"><em>v</em></span>,
|
||||
then the moment is undefined. Evaluating the moment will throw a <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
unless ignored by a policy, when it will return <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><>::</span><span class="identifier">quiet_NaN</span><span class="special">();</span></code>
|
||||
</p>
|
||||
<p>
|
||||
(For simplicity, we have not implemented the return of infinity in some
|
||||
cases as suggested by <a href="http://en.wikipedia.org/wiki/Student%27s_t-distribution" target="_top">Wikipedia
|
||||
Student's t</a>. See also <a href="https://svn.boost.org/trac/boost/ticket/7177" target="_top">https://svn.boost.org/trac/boost/ticket/7177</a>.)
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="skew_normal_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="triangular_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,446 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Triangular Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="students_t_dist.html" title="Students t Distribution">
|
||||
<link rel="next" href="uniform_dist.html" title="Uniform Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="students_t_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="uniform_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.triangular_dist"></a><a class="link" href="triangular_dist.html" title="Triangular Distribution">Triangular
|
||||
Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">triangular</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">triangular_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">triangular_distribution</span><span class="special"><></span> <span class="identifier">triangular</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">triangular_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">triangular_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">lower</span> <span class="special">=</span> <span class="special">-</span><span class="number">1</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">mode</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="identifier">RealType</span> <span class="identifier">upper</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span> <span class="comment">// Constructor.</span>
|
||||
<span class="special">:</span> <span class="identifier">m_lower</span><span class="special">(</span><span class="identifier">lower</span><span class="special">),</span> <span class="identifier">m_mode</span><span class="special">(</span><span class="identifier">mode</span><span class="special">),</span> <span class="identifier">m_upper</span><span class="special">(</span><span class="identifier">upper</span><span class="special">)</span> <span class="comment">// Default is -1, 0, +1 symmetric triangular distribution.</span>
|
||||
<span class="comment">// Accessor functions.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">lower</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">mode</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">upper</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="special">};</span> <span class="comment">// class triangular_distribution</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Triangular_distribution" target="_top">triangular
|
||||
distribution</a> is a <a href="http://en.wikipedia.org/wiki/Continuous_distribution" target="_top">continuous</a>
|
||||
<a href="http://en.wikipedia.org/wiki/Probability_distribution" target="_top">probability
|
||||
distribution</a> with a lower limit a, <a href="http://en.wikipedia.org/wiki/Mode_%28statistics%29" target="_top">mode
|
||||
c</a>, and upper limit b.
|
||||
</p>
|
||||
<p>
|
||||
The triangular distribution is often used where the distribution is only
|
||||
vaguely known, but, like the <a href="http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29" target="_top">uniform
|
||||
distribution</a>, upper and limits are 'known', but a 'best guess',
|
||||
the mode or center point, is also added. It has been recommended as a
|
||||
<a href="http://www.worldscibooks.com/mathematics/etextbook/5720/5720_chap1.pdf" target="_top">proxy
|
||||
for the beta distribution.</a> The distribution is used in business
|
||||
decision making and project planning.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Triangular_distribution" target="_top">triangular
|
||||
distribution</a> is a distribution with the <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability
|
||||
density function</a>:
|
||||
</p>
|
||||
<p>
|
||||
   f(x) =
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
2(x-a)/(b-a) (c-a) for a <= x <= c
|
||||
</li>
|
||||
<li class="listitem">
|
||||
2(b-x)/(b-a)(b-c) for c < x <= b
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
Parameter <span class="emphasis"><em>a</em></span> (lower) can be any finite value. Parameter
|
||||
<span class="emphasis"><em>b</em></span> (upper) can be any finite value > a (lower).
|
||||
Parameter <span class="emphasis"><em>c</em></span> (mode) a <= c <= b. This is the
|
||||
most probable value.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Random_variate" target="_top">random variate</a>
|
||||
x must also be finite, and is supported lower <= x <= upper.
|
||||
</p>
|
||||
<p>
|
||||
The triangular distribution may be appropriate when an assumption of a
|
||||
normal distribution is unjustified because uncertainty is caused by rounding
|
||||
and quantization from analog to digital conversion. Upper and lower limits
|
||||
are known, and the most probable value lies midway.
|
||||
</p>
|
||||
<p>
|
||||
The distribution simplifies when the 'best guess' is either the lower or
|
||||
upper limit - a 90 degree angle triangle. The 001 triangular distribution
|
||||
which expresses an estimate that the lowest value is the most likely; for
|
||||
example, you believe that the next-day quoted delivery date is most likely
|
||||
(knowing that a quicker delivery is impossible - the postman only comes
|
||||
once a day), and that longer delays are decreasingly likely, and delivery
|
||||
is assumed to never take more than your upper limit.
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates how the <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability
|
||||
density function PDF</a> varies with the various parameters:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/triangular_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
and cumulative distribution function
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/triangular_cdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.triangular_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.triangular_dist.member_functions"></a></span><a class="link" href="triangular_dist.html#math_toolkit.dist_ref.dists.triangular_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">triangular_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">lower</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">mode</span> <span class="special">=</span> <span class="number">0</span> <span class="identifier">RealType</span> <span class="identifier">upper</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a <a href="http://en.wikipedia.org/wiki/triangular_distribution" target="_top">triangular
|
||||
distribution</a> with lower <span class="emphasis"><em>lower</em></span> (a) and upper
|
||||
<span class="emphasis"><em>upper</em></span> (b).
|
||||
</p>
|
||||
<p>
|
||||
Requires that the <span class="emphasis"><em>lower</em></span>, <span class="emphasis"><em>mode</em></span>
|
||||
and <span class="emphasis"><em>upper</em></span> parameters are all finite, otherwise calls
|
||||
<a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<div class="warning"><table border="0" summary="Warning">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../../../doc/src/images/warning.png"></td>
|
||||
<th align="left">Warning</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
These constructors are slightly different from the analogs provided by
|
||||
<a href="http://mathworld.wolfram.com" target="_top">Wolfram MathWorld</a>
|
||||
<a href="http://reference.wolfram.com/language/ref/TriangularDistribution.html" target="_top">Triangular
|
||||
distribution</a>, where
|
||||
</p>
|
||||
<p>
|
||||
<code class="literal">TriangularDistribution[{min, max}]</code> represents a <span class="bold"><strong>symmetric</strong></span> triangular statistical distribution
|
||||
giving values between min and max.<br> <code class="literal">TriangularDistribution[]</code>
|
||||
represents a <span class="bold"><strong>symmetric</strong></span> triangular statistical
|
||||
distribution giving values between 0 and 1.<br> <code class="literal">TriangularDistribution[{min,
|
||||
max}, c]</code> represents a triangular distribution with mode at
|
||||
c (usually <span class="bold"><strong>asymmetric</strong></span>).<br>
|
||||
</p>
|
||||
<p>
|
||||
So, for example, to compute a variance using <a href="http://www.wolframalpha.com/" target="_top">Wolfram
|
||||
Alpha</a>, use <code class="literal">N[variance[TriangularDistribution{1, +2}],
|
||||
50]</code>
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
The parameters of a distribution can be obtained using these member functions:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">lower</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>lower</em></span> parameter of this distribution (default
|
||||
-1).
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">mode</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>mode</em></span> parameter of this distribution (default
|
||||
0).
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">upper</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>upper</em></span> parameter of this distribution (default+1).
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.triangular_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.triangular_dist.non_member_accessors"></a></span><a class="link" href="triangular_dist.html#math_toolkit.dist_ref.dists.triangular_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is \lowerto \upper, and the supported
|
||||
range is lower <= x <= upper.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.triangular_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.triangular_dist.accuracy"></a></span><a class="link" href="triangular_dist.html#math_toolkit.dist_ref.dists.triangular_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The triangular distribution is implemented with simple arithmetic operators
|
||||
and so should have errors within an epsilon or two, except quantiles with
|
||||
arguments nearing the extremes of zero and unity.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.triangular_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.triangular_dist.implementation"></a></span><a class="link" href="triangular_dist.html#math_toolkit.dist_ref.dists.triangular_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table, a is the <span class="emphasis"><em>lower</em></span> parameter of
|
||||
the distribution, c is the <span class="emphasis"><em>mode</em></span> parameter, b is the
|
||||
<span class="emphasis"><em>upper</em></span> parameter, <span class="emphasis"><em>x</em></span> is the random
|
||||
variate, <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = 0 for x < mode, 2(x-a)/(b-a)(c-a)
|
||||
else 2*(b-x)/((b-a)(b-c))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: cdf = 0 for x < mode (x-a)<sup>2</sup>/((b-a)(c-a))
|
||||
else 1 - (b-x)<sup>2</sup>/((b-a)(b-c))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = 1 - p
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
let p0 = (c-a)/(b-a) the point of inflection on the cdf, then
|
||||
given probability p and q = 1-p:
|
||||
</p>
|
||||
<p>
|
||||
x = sqrt((b-a)(c-a)p) + a ; for p < p0
|
||||
</p>
|
||||
<p>
|
||||
x = c ; for p == p0
|
||||
</p>
|
||||
<p>
|
||||
x = b - sqrt((b-a)(b-c)q) ; for p > p0
|
||||
</p>
|
||||
<p>
|
||||
(See <a href="../../../../../../../boost/math/distributions/triangular.hpp" target="_top">/boost/math/distributions/triangular.hpp</a>
|
||||
for details.)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
As quantile (See <a href="../../../../../../../boost/math/distributions/triangular.hpp" target="_top">/boost/math/distributions/triangular.hpp</a>
|
||||
for details.)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(a + b + 3) / 3
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(a<sup>2</sup>+b<sup>2</sup>+c<sup>2</sup> - ab - ac - bc)/18
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
c
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(See <a href="../../../../../../../boost/math/distributions/triangular.hpp" target="_top">/boost/math/distributions/triangular.hpp</a>
|
||||
for details).
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12/5
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
-3/5
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<p>
|
||||
Some 'known good' test values were obtained using <a href="http://www.wolframalpha.com/" target="_top">Wolfram
|
||||
Alpha</a>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.triangular_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.triangular_dist.references"></a></span><a class="link" href="triangular_dist.html#math_toolkit.dist_ref.dists.triangular_dist.references">References</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://en.wikipedia.org/wiki/Triangular_distribution" target="_top">Wikpedia
|
||||
triangular distribution</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://mathworld.wolfram.com/TriangularDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Triangular Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Evans, M.; Hastings, N.; and Peacock, B. "Triangular Distribution."
|
||||
Ch. 40 in Statistical Distributions, 3rd ed. New York: Wiley, pp. 187-188,
|
||||
2000, ISBN - 0471371246.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.measurement.sk/2002/S1/Wimmer2.pdf" target="_top">Gejza Wimmer,
|
||||
Viktor Witkovsky and Tomas Duby, Measurement Science Review, Volume
|
||||
2, Section 1, 2002, Proper Rounding Of The Measurement Results Under
|
||||
The Assumption Of Triangular Distribution.</a>
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="students_t_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="uniform_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,367 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Uniform Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="triangular_dist.html" title="Triangular Distribution">
|
||||
<link rel="next" href="weibull_dist.html" title="Weibull Distribution">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="triangular_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="weibull_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.uniform_dist"></a><a class="link" href="uniform_dist.html" title="Uniform Distribution">Uniform Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">uniform</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">uniform_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">uniform_distribution</span><span class="special"><></span> <span class="identifier">uniform</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">uniform_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">uniform_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">lower</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">upper</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span> <span class="comment">// Constructor.</span>
|
||||
<span class="special">:</span> <span class="identifier">m_lower</span><span class="special">(</span><span class="identifier">lower</span><span class="special">),</span> <span class="identifier">m_upper</span><span class="special">(</span><span class="identifier">upper</span><span class="special">)</span> <span class="comment">// Default is standard uniform distribution.</span>
|
||||
<span class="comment">// Accessor functions.</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">lower</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">upper</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="special">};</span> <span class="comment">// class uniform_distribution</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The uniform distribution, also known as a rectangular distribution, is
|
||||
a probability distribution that has constant probability.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29" target="_top">continuous
|
||||
uniform distribution</a> is a distribution with the <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability
|
||||
density function</a>:
|
||||
</p>
|
||||
<p>
|
||||
f(x) =
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
1 / (upper - lower) for lower < x < upper
|
||||
</li>
|
||||
<li class="listitem">
|
||||
zero for x < lower or x > upper
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
and in this implementation:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
|
||||
1 / (upper - lower) for x = lower or x = upper
|
||||
</li></ul></div>
|
||||
<p>
|
||||
The choice of x = lower or x = upper is made because statistical use of
|
||||
this distribution judged is most likely: the method of maximum likelihood
|
||||
uses this definition.
|
||||
</p>
|
||||
<p>
|
||||
There is also a <a href="http://en.wikipedia.org/wiki/Discrete_uniform_distribution" target="_top"><span class="bold"><strong>discrete</strong></span> uniform distribution</a>.
|
||||
</p>
|
||||
<p>
|
||||
Parameters lower and upper can be any finite value.
|
||||
</p>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Random_variate" target="_top">random variate</a>
|
||||
x must also be finite, and is supported lower <= x <= upper.
|
||||
</p>
|
||||
<p>
|
||||
The lower parameter is also called the <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda364.htm" target="_top">location
|
||||
parameter</a>, <a href="http://en.wikipedia.org/wiki/Location_parameter" target="_top">that
|
||||
is where the origin of a plot will lie</a>, and (upper - lower) is
|
||||
also called the <a href="http://en.wikipedia.org/wiki/Scale_parameter" target="_top">scale
|
||||
parameter</a>.
|
||||
</p>
|
||||
<p>
|
||||
The following graph illustrates how the <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability
|
||||
density function PDF</a> varies with the shape parameter:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/uniform_pdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
Likewise for the CDF:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/uniform_cdf.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.uniform_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.uniform_dist.member_functions"></a></span><a class="link" href="uniform_dist.html#math_toolkit.dist_ref.dists.uniform_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">uniform_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">lower</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">upper</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a <a href="http://en.wikipedia.org/wiki/uniform_distribution" target="_top">uniform
|
||||
distribution</a> with lower <span class="emphasis"><em>lower</em></span> (a) and upper
|
||||
<span class="emphasis"><em>upper</em></span> (b).
|
||||
</p>
|
||||
<p>
|
||||
Requires that the <span class="emphasis"><em>lower</em></span> and <span class="emphasis"><em>upper</em></span>
|
||||
parameters are both finite; otherwise if infinity or NaN then calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">lower</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>lower</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">upper</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>upper</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.uniform_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.uniform_dist.non_member_accessors"></a></span><a class="link" href="uniform_dist.html#math_toolkit.dist_ref.dists.uniform_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is any finite value, but the supported
|
||||
range is only <span class="emphasis"><em>lower</em></span> <= x <= <span class="emphasis"><em>upper</em></span>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.uniform_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.uniform_dist.accuracy"></a></span><a class="link" href="uniform_dist.html#math_toolkit.dist_ref.dists.uniform_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The uniform distribution is implemented with simple arithmetic operators
|
||||
and so should have errors within an epsilon or two.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.uniform_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.uniform_dist.implementation"></a></span><a class="link" href="uniform_dist.html#math_toolkit.dist_ref.dists.uniform_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table a is the <span class="emphasis"><em>lower</em></span> parameter of
|
||||
the distribution, b is the <span class="emphasis"><em>upper</em></span> parameter, <span class="emphasis"><em>x</em></span>
|
||||
is the random variate, <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q
|
||||
= 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = 0 for x < a, 1 / (b - a) for a <=
|
||||
x <= b, 0 for x > b
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: cdf = 0 for x < a, (x - a) / (b - a) for
|
||||
a <= x <= b, 1 for x > b
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = 1 - p, (b - x) / (b - a)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = p * (b - a) + a;
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
x = -q * (b - a) + b
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(a + b) / 2
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
(b - a) <sup>2</sup> / 12
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
any value in [a, b] but a is chosen. (Would NaN be better?)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
0
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
-6/5 = -1.2 exactly. (kurtosis - 3)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
9/5
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.uniform_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.uniform_dist.references"></a></span><a class="link" href="uniform_dist.html#math_toolkit.dist_ref.dists.uniform_dist.references">References</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29" target="_top">Wikpedia
|
||||
continuous uniform distribution</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://mathworld.wolfram.com/UniformDistribution.html" target="_top">Weisstein,
|
||||
Weisstein, Eric W. "Uniform Distribution." From MathWorld--A
|
||||
Wolfram Web Resource.</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3662.htm" target="_top">http://www.itl.nist.gov/div898/handbook/eda/section3/eda3662.htm</a>
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="triangular_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="weibull_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,369 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Weibull Distribution</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dists.html" title="Distributions">
|
||||
<link rel="prev" href="uniform_dist.html" title="Uniform Distribution">
|
||||
<link rel="next" href="../dist_algorithms.html" title="Distribution Algorithms">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="uniform_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="../dist_algorithms.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.dist_ref.dists.weibull_dist"></a><a class="link" href="weibull_dist.html" title="Weibull Distribution">Weibull Distribution</a>
|
||||
</h4></div></div></div>
|
||||
<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">weibull</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. 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>
|
||||
<span class="keyword">class</span> <span class="identifier">weibull_distribution</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">weibull_distribution</span><span class="special"><></span> <span class="identifier">weibull</span><span class="special">;</span>
|
||||
|
||||
<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">class</span> <a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">weibull_distribution</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
|
||||
<span class="comment">// Construct:</span>
|
||||
<span class="identifier">weibull_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">shape</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">// Accessors:</span>
|
||||
<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="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<p>
|
||||
The <a href="http://en.wikipedia.org/wiki/Weibull_distribution" target="_top">Weibull
|
||||
distribution</a> is a continuous distribution with the <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability
|
||||
density function</a>:
|
||||
</p>
|
||||
<p>
|
||||
f(x; α, β) = (α/β) * (x / β)<sup>α - 1</sup> * e<sup>-(x/β)<sup>α</sup></sup>
|
||||
</p>
|
||||
<p>
|
||||
For shape parameter α   > 0, and scale parameter β   > 0, and x > 0.
|
||||
</p>
|
||||
<p>
|
||||
The Weibull distribution is often used in the field of failure analysis;
|
||||
in particular it can mimic distributions where the failure rate varies
|
||||
over time. If the failure rate is:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
constant over time, then α   = 1, suggests that items are failing from
|
||||
random events.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
decreases over time, then α   < 1, suggesting "infant mortality".
|
||||
</li>
|
||||
<li class="listitem">
|
||||
increases over time, then α   > 1, suggesting "wear out" -
|
||||
more likely to fail as time goes by.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
The following graph illustrates how the PDF varies with the shape parameter
|
||||
α:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/weibull_pdf1.svg" align="middle"></span>
|
||||
</p>
|
||||
<p>
|
||||
While this graph illustrates how the PDF varies with the scale parameter
|
||||
β:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../../graphs/weibull_pdf2.svg" align="middle"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.weibull_dist.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.weibull_dist.related_distributions"></a></span><a class="link" href="weibull_dist.html#math_toolkit.dist_ref.dists.weibull_dist.related_distributions">Related
|
||||
distributions</a>
|
||||
</h5>
|
||||
<p>
|
||||
When α   = 3, the <a href="http://en.wikipedia.org/wiki/Weibull_distribution" target="_top">Weibull
|
||||
distribution</a> appears similar to the <a href="http://en.wikipedia.org/wiki/Normal_distribution" target="_top">normal
|
||||
distribution</a>. When α   = 1, the Weibull distribution reduces to the
|
||||
<a href="http://en.wikipedia.org/wiki/Exponential_distribution" target="_top">exponential
|
||||
distribution</a>. The relationship of the types of extreme value distributions,
|
||||
of which the Weibull is but one, is discussed by <a href="http://www.worldscibooks.com/mathematics/p191.html" target="_top">Extreme
|
||||
Value Distributions, Theory and Applications Samuel Kotz & Saralees
|
||||
Nadarajah</a>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.weibull_dist.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.weibull_dist.member_functions"></a></span><a class="link" href="weibull_dist.html#math_toolkit.dist_ref.dists.weibull_dist.member_functions">Member
|
||||
Functions</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="identifier">weibull_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">shape</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>
|
||||
</pre>
|
||||
<p>
|
||||
Constructs a <a href="http://en.wikipedia.org/wiki/Weibull_distribution" target="_top">Weibull
|
||||
distribution</a> with shape <span class="emphasis"><em>shape</em></span> and scale <span class="emphasis"><em>scale</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Requires that the <span class="emphasis"><em>shape</em></span> and <span class="emphasis"><em>scale</em></span>
|
||||
parameters are both greater than zero, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>shape</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<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>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <span class="emphasis"><em>scale</em></span> parameter of this distribution.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.weibull_dist.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.weibull_dist.non_member_accessors"></a></span><a class="link" href="weibull_dist.html#math_toolkit.dist_ref.dists.weibull_dist.non_member_accessors">Non-member
|
||||
Accessors</a>
|
||||
</h5>
|
||||
<p>
|
||||
All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
|
||||
functions</a> that are generic to all distributions are supported:
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
|
||||
<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>,
|
||||
<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>,
|
||||
<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>,
|
||||
<a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
|
||||
<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>,
|
||||
<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>.
|
||||
</p>
|
||||
<p>
|
||||
The domain of the random variable is [0, ∞].
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.weibull_dist.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.weibull_dist.accuracy"></a></span><a class="link" href="weibull_dist.html#math_toolkit.dist_ref.dists.weibull_dist.accuracy">Accuracy</a>
|
||||
</h5>
|
||||
<p>
|
||||
The Weibull distribution is implemented in terms of the standard library
|
||||
<code class="computeroutput"><span class="identifier">log</span></code> and <code class="computeroutput"><span class="identifier">exp</span></code>
|
||||
functions plus <a class="link" href="../../powers/expm1.html" title="expm1">expm1</a> and
|
||||
<a class="link" href="../../powers/log1p.html" title="log1p">log1p</a> and as such should
|
||||
have very low error rates.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.weibull_dist.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.weibull_dist.implementation"></a></span><a class="link" href="weibull_dist.html#math_toolkit.dist_ref.dists.weibull_dist.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
In the following table α   is the shape parameter of the distribution, β   is its
|
||||
scale parameter, <span class="emphasis"><em>x</em></span> is the random variate, <span class="emphasis"><em>p</em></span>
|
||||
is the probability and <span class="emphasis"><em>q = 1-p</em></span>.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Implementation Notes
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
pdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: pdf = αβ<sup>-α </sup>x<sup>α - 1</sup> e<sup>-(x/beta)<sup>alpha</sup></sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: p = -<a class="link" href="../../powers/expm1.html" title="expm1">expm1</a>(-(x/β)<sup>α</sup>)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cdf complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: q = e<sup>-(x/β)<sup>α</sup></sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = β * (-<a class="link" href="../../powers/log1p.html" title="log1p">log1p</a>(-p))<sup>1/α</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
quantile from the complement
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Using the relation: x = β * (-log(q))<sup>1/α</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mean
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
β * Γ(1 + 1/α)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
variance
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
β<sup>2</sup>(Γ(1 + 2/α) - Γ<sup>2</sup>(1 + 1/α))
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
mode
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
β((α - 1) / α)<sup>1/α</sup>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
skewness
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Refer to <a href="http://mathworld.wolfram.com/WeibullDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Weibull Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Refer to <a href="http://mathworld.wolfram.com/WeibullDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Weibull Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
kurtosis excess
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Refer to <a href="http://mathworld.wolfram.com/WeibullDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Weibull Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.dists.weibull_dist.h5"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.dists.weibull_dist.references"></a></span><a class="link" href="weibull_dist.html#math_toolkit.dist_ref.dists.weibull_dist.references">References</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://en.wikipedia.org/wiki/Weibull_distribution" target="_top">http://en.wikipedia.org/wiki/Weibull_distribution</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://mathworld.wolfram.com/WeibullDistribution.html" target="_top">Weisstein,
|
||||
Eric W. "Weibull Distribution." From MathWorld--A Wolfram
|
||||
Web Resource.</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3668.htm" target="_top">Weibull
|
||||
in NIST Exploratory Data Analysis</a>
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="uniform_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="../dist_algorithms.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,706 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Non-Member Properties</title>
|
||||
<link rel="stylesheet" href="../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../dist_ref.html" title="Statistical Distributions Reference">
|
||||
<link rel="prev" href="../dist_ref.html" title="Statistical Distributions Reference">
|
||||
<link rel="next" href="dists.html" title="Distributions">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../dist_ref.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dist_ref.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="dists.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="math_toolkit.dist_ref.nmp"></a><a class="link" href="nmp.html" title="Non-Member Properties">Non-Member Properties</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Properties that are common to all distributions are accessed via non-member
|
||||
getter functions: non-membership allows more of these functions to be added
|
||||
over time, as the need arises. Unfortunately the literature uses many different
|
||||
and confusing names to refer to a rather small number of actual concepts;
|
||||
refer to the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.concept_index">concept
|
||||
index</a> to find the property you want by the name you are most familiar
|
||||
with. Or use the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.function_index">function
|
||||
index</a> to go straight to the function you want if you already know
|
||||
its name.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.function_index"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.function_index">Function
|
||||
Index</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution
|
||||
Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.ccdf">Complement of the Cumulative
|
||||
Distribution Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.kurtosis">kurtosis</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.mean">mean</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.median">median</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.mode">mode</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.range">range</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.quantile_c">Quantile from the
|
||||
complement of the probability</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.skewness">skewness</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.support">support</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.variance">variance</a>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.concept_index"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.concept_index">Conceptual
|
||||
Index</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.ccdf">Complement of the Cumulative
|
||||
Distribution Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution
|
||||
Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdf_inv">Inverse Cumulative
|
||||
Distribution Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.survival_inv">Inverse Survival
|
||||
Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard Function</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.lower_critical">Lower Critical
|
||||
Value</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.kurtosis">kurtosis</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.mean">mean</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.median">median</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.mode">mode</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdfPQ">P</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.percent">Percent Point Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.pmf">Probability Mass Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.range">range</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdfPQ">Q</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.quantile_c">Quantile from the
|
||||
complement of the probability</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.skewness">skewness</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.survival">Survival Function</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.support">support</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.upper_critical">Upper Critical
|
||||
Value</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.variance">variance</a>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.cdf"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative
|
||||
Distribution Function</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><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">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">cdf</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">RealType</span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
The <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution
|
||||
Function</a> is the probability that the variable takes a value less than
|
||||
or equal to x. It is equivalent to the integral from -infinity to x of the
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>.
|
||||
</p>
|
||||
<p>
|
||||
This function may return a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the random variable is outside the defined range for the distribution.
|
||||
</p>
|
||||
<p>
|
||||
For example, the following graph shows the cdf for the normal distribution:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../graphs/cdf.png"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h3"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.ccdf"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.ccdf">Complement
|
||||
of the Cumulative Distribution Function</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Distribution</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">RealType</span><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">cdf</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Unspecified-Complement-Type</em></span><span class="special"><</span><span class="identifier">Distribution</span><span class="special">,</span> <span class="identifier">RealType</span><span class="special">>&</span> <span class="identifier">comp</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
The complement of the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative
|
||||
Distribution Function</a> is the probability that the variable takes a
|
||||
value greater than x. It is equivalent to the integral from x to infinity
|
||||
of the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density
|
||||
Function</a>, or 1 minus the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative
|
||||
Distribution Function</a> of x.
|
||||
</p>
|
||||
<p>
|
||||
This is also known as the survival function.
|
||||
</p>
|
||||
<p>
|
||||
This function may return a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the random variable is outside the defined range for the distribution.
|
||||
</p>
|
||||
<p>
|
||||
In this library, it is obtained by wrapping the arguments to the <code class="computeroutput"><span class="identifier">cdf</span></code> function in a call to <code class="computeroutput"><span class="identifier">complement</span></code>, for example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="comment">// standard normal distribution object:</span>
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">normal</span> <span class="identifier">norm</span><span class="special">;</span>
|
||||
<span class="comment">// print survival function for x=2.0:</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">cdf</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">norm</span><span class="special">,</span> <span class="number">2.0</span><span class="special">))</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
For example, the following graph shows the __complement of the cdf for the
|
||||
normal distribution:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../graphs/survival.png"></span>
|
||||
</p>
|
||||
<p>
|
||||
See <a class="link" href="../stat_tut/overview/complements.html#why_complements">why complements?</a> for why the complement
|
||||
is useful and when it should be used.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h4"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.hazard"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard
|
||||
Function</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><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">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">hazard</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">RealType</span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard Function</a>
|
||||
of <span class="emphasis"><em>x</em></span> and distibution <span class="emphasis"><em>dist</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
This function may return a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the random variable is outside the defined range for the distribution.
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../equations/hazard.svg"></span>
|
||||
</p>
|
||||
<div class="caution"><table border="0" summary="Caution">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../doc/src/images/caution.png"></td>
|
||||
<th align="left">Caution</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
Some authors refer to this as the conditional failure density function
|
||||
rather than the hazard function.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h5"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.chf"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative
|
||||
Hazard Function</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><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">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">chf</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">RealType</span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard
|
||||
Function</a> of <span class="emphasis"><em>x</em></span> and distibution <span class="emphasis"><em>dist</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
This function may return a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the random variable is outside the defined range for the distribution.
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../equations/chf.svg"></span>
|
||||
</p>
|
||||
<div class="caution"><table border="0" summary="Caution">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../doc/src/images/caution.png"></td>
|
||||
<th align="left">Caution</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
Some authors refer to this as simply the "Hazard Function".
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h6"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.mean"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.mean">mean</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><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">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the mean of the distribution <span class="emphasis"><em>dist</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
This function may return a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the distribution does not have a defined mean (for example the Cauchy
|
||||
distribution).
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h7"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.median"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.median">median</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><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">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">median</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the median of the distribution <span class="emphasis"><em>dist</em></span>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h8"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.mode"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.mode">mode</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">mode</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the mode of the distribution <span class="emphasis"><em>dist</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
This function may return a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the distribution does not have a defined mode.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h9"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.pdf"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability
|
||||
Density Function</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><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">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">pdf</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">RealType</span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
For a continuous function, the probability density function (pdf) returns
|
||||
the probability that the variate has the value x. Since for continuous distributions
|
||||
the probability at a single point is actually zero, the probability is better
|
||||
expressed as the integral of the pdf between two points: see the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative
|
||||
Distribution Function</a>.
|
||||
</p>
|
||||
<p>
|
||||
For a discrete distribution, the pdf is the probability that the variate
|
||||
takes the value x.
|
||||
</p>
|
||||
<p>
|
||||
This function may return a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the random variable is outside the defined range for the distribution.
|
||||
</p>
|
||||
<p>
|
||||
For example, for a standard normal distribution the pdf looks like this:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../graphs/pdf.png"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h10"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.range"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.range">Range</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><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">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <span class="identifier">RealType</span><span class="special">></span> <span class="identifier">range</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the valid range of the random variable over distribution <span class="emphasis"><em>dist</em></span>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h11"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.quantile"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><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">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">quantile</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">RealType</span><span class="special">&</span> <span class="identifier">p</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
The quantile is best viewed as the inverse of the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative
|
||||
Distribution Function</a>, it returns a value <span class="emphasis"><em>x</em></span> such
|
||||
that <code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">dist</span><span class="special">,</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">==</span>
|
||||
<span class="identifier">p</span></code>.
|
||||
</p>
|
||||
<p>
|
||||
This is also known as the <span class="emphasis"><em>percent point function</em></span>, or
|
||||
<span class="emphasis"><em>percentile</em></span>, or <span class="emphasis"><em>fractile</em></span>, it is
|
||||
also the same as calculating the <span class="emphasis"><em>lower critical value</em></span>
|
||||
of a distribution.
|
||||
</p>
|
||||
<p>
|
||||
This function returns a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the probability lies outside [0,1]. The function may return an <a class="link" href="../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>
|
||||
if there is no finite value that has the specified probability.
|
||||
</p>
|
||||
<p>
|
||||
The following graph shows the quantile function for a standard normal distribution:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../graphs/quantile.png"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h12"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.quantile_c"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.quantile_c">Quantile
|
||||
from the complement of the probability.</a>
|
||||
</h5>
|
||||
<p>
|
||||
See also <a class="link" href="../stat_tut/overview/complements.html" title="Complements are supported too - and when to use them">complements</a>.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Distribution</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">RealType</span><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">quantile</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Unspecified-Complement-Type</em></span><span class="special"><</span><span class="identifier">Distribution</span><span class="special">,</span> <span class="identifier">RealType</span><span class="special">>&</span> <span class="identifier">comp</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
This is the inverse of the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.ccdf">Complement
|
||||
of the Cumulative Distribution Function</a>. It is calculated by wrapping
|
||||
the arguments in a call to the quantile function in a call to <span class="emphasis"><em>complement</em></span>.
|
||||
For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="comment">// define a standard normal distribution:</span>
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">normal</span> <span class="identifier">norm</span><span class="special">;</span>
|
||||
<span class="comment">// print the value of x for which the complement</span>
|
||||
<span class="comment">// of the probability is 0.05:</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">norm</span><span class="special">,</span> <span class="number">0.05</span><span class="special">))</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
The function computes a value <span class="emphasis"><em>x</em></span> such that <code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">dist</span><span class="special">,</span>
|
||||
<span class="identifier">x</span><span class="special">))</span> <span class="special">==</span> <span class="identifier">q</span></code> where
|
||||
<span class="emphasis"><em>q</em></span> is complement of the probability.
|
||||
</p>
|
||||
<p>
|
||||
<a class="link" href="../stat_tut/overview/complements.html#why_complements">Why complements?</a>
|
||||
</p>
|
||||
<p>
|
||||
This function is also called the inverse survival function, and is the same
|
||||
as calculating the <span class="emphasis"><em>upper critical value</em></span> of a distribution.
|
||||
</p>
|
||||
<p>
|
||||
This function returns a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the probablity lies outside [0,1]. The function may return an <a class="link" href="../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>
|
||||
if there is no finite value that has the specified probability.
|
||||
</p>
|
||||
<p>
|
||||
The following graph show the inverse survival function for the normal distribution:
|
||||
</p>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../graphs/survival_inv.png"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h13"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.sd"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.sd">Standard
|
||||
Deviation</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><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">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">standard_deviation</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the standard deviation of distribution <span class="emphasis"><em>dist</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
This function may return a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the distribution does not have a defined standard deviation.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h14"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.support"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.support">support</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><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">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <span class="identifier">RealType</span><span class="special">></span> <span class="identifier">support</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the supported range of random variable over the distribution <span class="emphasis"><em>dist</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
The distribution is said to be 'supported' over a range that is <a href="http://en.wikipedia.org/wiki/Probability_distribution" target="_top">"the
|
||||
smallest closed set whose complement has probability zero"</a>.
|
||||
Non-mathematicians might say it means the 'interesting' smallest range of
|
||||
random variate x that has the cdf going from zero to unity. Outside are uninteresting
|
||||
zones where the pdf is zero, and the cdf zero or unity.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h15"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.variance"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.variance">Variance</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><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">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the variance of the distribution <span class="emphasis"><em>dist</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
This function may return a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the distribution does not have a defined variance.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h16"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.skewness"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.skewness">Skewness</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><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">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">skewness</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the skewness of the distribution <span class="emphasis"><em>dist</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
This function may return a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the distribution does not have a defined skewness.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h17"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.kurtosis"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.kurtosis">Kurtosis</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><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">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">kurtosis</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the 'proper' kurtosis (normalized fourth moment) of the distribution
|
||||
<span class="emphasis"><em>dist</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
kertosis = β<sub>2</sub>  = μ<sub>4</sub>   / μ<sub>2</sub><sup>2</sup>
|
||||
</p>
|
||||
<p>
|
||||
Where μ<sub>i</sub>   is the i'th central moment of the distribution, and in particular
|
||||
μ<sub>2</sub>   is the variance of the distribution.
|
||||
</p>
|
||||
<p>
|
||||
The kurtosis is a measure of the "peakedness" of a distribution.
|
||||
</p>
|
||||
<p>
|
||||
Note that the literature definition of kurtosis is confusing. The definition
|
||||
used here is that used by for example <a href="http://mathworld.wolfram.com/Kurtosis.html" target="_top">Wolfram
|
||||
MathWorld</a> (that includes a table of formulae for kurtosis excess
|
||||
for various distributions) but NOT the definition of <a href="http://en.wikipedia.org/wiki/Kurtosis" target="_top">kurtosis
|
||||
used by Wikipedia</a> which treats "kurtosis" and "kurtosis
|
||||
excess" as the same quantity.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">kurtosis_excess</span> <span class="special">=</span> <span class="char">'proper'</span> <span class="identifier">kurtosis</span> <span class="special">-</span> <span class="number">3</span>
|
||||
</pre>
|
||||
<p>
|
||||
This subtraction of 3 is convenient so that the <span class="emphasis"><em>kurtosis excess</em></span>
|
||||
of a normal distribution is zero.
|
||||
</p>
|
||||
<p>
|
||||
This function may return a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the distribution does not have a defined kurtosis.
|
||||
</p>
|
||||
<p>
|
||||
'Proper' kurtosis can have a value from zero to + infinity.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h18"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.kurtosis_excess"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">Kurtosis
|
||||
excess</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
|
||||
<span class="identifier">RealType</span> <span class="identifier">kurtosis_excess</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>Distribution-Type</em></span><span class="special"><</span><span class="identifier">RealType</span><span class="special">,</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">>&</span> <span class="identifier">dist</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the kurtosis excess of the distribution <span class="emphasis"><em>dist</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
kurtosis excess = γ<sub>2</sub>  = μ<sub>4</sub>   / μ<sub>2</sub><sup>2</sup>  - 3 = kurtosis - 3
|
||||
</p>
|
||||
<p>
|
||||
Where μ<sub>i</sub>   is the i'th central moment of the distribution, and in particular
|
||||
μ<sub>2</sub>   is the variance of the distribution.
|
||||
</p>
|
||||
<p>
|
||||
The kurtosis excess is a measure of the "peakedness" of a distribution,
|
||||
and is more widely used than the "kurtosis proper". It is defined
|
||||
so that the kurtosis excess of a normal distribution is zero.
|
||||
</p>
|
||||
<p>
|
||||
This function may return a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
|
||||
if the distribution does not have a defined kurtosis excess.
|
||||
</p>
|
||||
<p>
|
||||
Kurtosis excess can have a value from -2 to + infinity.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">kurtosis</span> <span class="special">=</span> <span class="identifier">kurtosis_excess</span> <span class="special">+</span><span class="number">3</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
The kurtosis excess of a normal distribution is zero.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h19"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.cdfPQ"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdfPQ">P
|
||||
and Q</a>
|
||||
</h5>
|
||||
<p>
|
||||
The terms P and Q are sometimes used to refer to the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative
|
||||
Distribution Function</a> and its <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.ccdf">complement</a>
|
||||
respectively. Lowercase p and q are sometimes used to refer to the values
|
||||
returned by these functions.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h20"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.percent"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.percent">Percent
|
||||
Point Function or Percentile</a>
|
||||
</h5>
|
||||
<p>
|
||||
The percent point function, also known as the percentile, is the same as
|
||||
the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h21"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.cdf_inv"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.cdf_inv">Inverse
|
||||
CDF Function.</a>
|
||||
</h5>
|
||||
<p>
|
||||
The inverse of the cumulative distribution function, is the same as the
|
||||
<a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h22"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.survival_inv"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.survival_inv">Inverse
|
||||
Survival Function.</a>
|
||||
</h5>
|
||||
<p>
|
||||
The inverse of the survival function, is the same as computing the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.quantile_c">quantile from the complement
|
||||
of the probability</a>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h23"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.pmf"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.pmf">Probability
|
||||
Mass Function</a>
|
||||
</h5>
|
||||
<p>
|
||||
The Probability Mass Function is the same as the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability
|
||||
Density Function</a>.
|
||||
</p>
|
||||
<p>
|
||||
The term Mass Function is usually applied to discrete distributions, while
|
||||
the term <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density
|
||||
Function</a> applies to continuous distributions.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h24"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.lower_critical"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.lower_critical">Lower
|
||||
Critical Value.</a>
|
||||
</h5>
|
||||
<p>
|
||||
The lower critical value calculates the value of the random variable given
|
||||
the area under the left tail of the distribution. It is equivalent to calculating
|
||||
the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h25"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.upper_critical"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.upper_critical">Upper
|
||||
Critical Value.</a>
|
||||
</h5>
|
||||
<p>
|
||||
The upper critical value calculates the value of the random variable given
|
||||
the area under the right tail of the distribution. It is equivalent to calculating
|
||||
the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.quantile_c">quantile from the
|
||||
complement of the probability</a>.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.dist_ref.nmp.h26"></a>
|
||||
<span class="phrase"><a name="math_toolkit.dist_ref.nmp.survival"></a></span><a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.survival">Survival
|
||||
Function</a>
|
||||
</h5>
|
||||
<p>
|
||||
Refer to the <a class="link" href="nmp.html#math_toolkit.dist_ref.nmp.ccdf">Complement of
|
||||
the Cumulative Distribution Function</a>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../dist_ref.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dist_ref.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="dists.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user