<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.10.0">
+<link rel="home" href="../../../index.html" title="Math Toolkit 2.11.0">
<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">
<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 19. 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> <a class="link" href="../../../policy.html" title="Chapter 20. Policies: Controlling Precision, Error Handling etc">Policy</a> <span class="special">=</span> <a class="link" href="../../pol_ref/pol_ref_ref.html" title="Policy Class Reference">policies::policy<></a> <span class="special">></span>
<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>
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>
+<div class="blockquote"><blockquote class="blockquote"><p>
+ <span class="inlinemediaobject"><img src="../../../../graphs/hypergeometric_pdf_1.svg" align="middle"></span>
+
+ </p></blockquote></div>
<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>
+<div class="blockquote"><blockquote class="blockquote"><p>
+ <span class="inlinemediaobject"><img src="../../../../graphs/hypergeometric_pdf_2.svg" align="middle"></span>
+
+ </p></blockquote></div>
<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
</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 19. Policies: Controlling Precision, Error Handling etc">Policy</a> that requires (or produces) a real valued
+ always returns an integral value, therefore attempting to use a <a class="link" href="../../../policy.html" title="Chapter 20. 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>
<p>
The PDF can be calculated directly using the formula:
</p>
-<p>
- <span class="inlinemediaobject"><img src="../../../../equations/hypergeometric1.svg"></span>
- </p>
+<div class="blockquote"><blockquote class="blockquote"><p>
+ <span class="inlinemediaobject"><img src="../../../../equations/hypergeometric1.svg"></span>
+
+ </p></blockquote></div>
<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
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>
+<div class="blockquote"><blockquote class="blockquote"><p>
+ <span class="inlinemediaobject"><img src="../../../../equations/hypergeometric2.svg"></span>
+
+ </p></blockquote></div>
<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>
+<div class="blockquote"><blockquote class="blockquote"><p>
+ <span class="inlinemediaobject"><img src="../../../../equations/hypergeometric3.svg"></span>
+
+ </p></blockquote></div>
<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>
+<div class="blockquote"><blockquote class="blockquote"><p>
+ <span class="inlinemediaobject"><img src="../../../../equations/hypergeometric4.svg"></span>
+
+ </p></blockquote></div>
<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
(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>
+<div class="blockquote"><blockquote class="blockquote"><p>
+ <span class="inlinemediaobject"><img src="../../../../equations/hypergeometric5.svg"></span>
+
+ </p></blockquote></div>
<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.
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 class="blockquote"><blockquote class="blockquote"><p>
+ <span class="inlinemediaobject"><img src="../../../../equations/hypergeometric6.svg"></span>
+
+ </p></blockquote></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>