2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Merge pull request #642 from boostorg/hypergeomkurtosis

Hypergeomkurtosis
This commit is contained in:
Paul A. Bristow
2021-06-26 12:24:22 +01:00
committed by GitHub
15 changed files with 178 additions and 78 deletions

View File

@@ -15,7 +15,7 @@
typedef RealType value_type;
typedef Policy policy_type;
// Construct:
hypergeometric_distribution(unsigned r, unsigned n, unsigned N);
hypergeometric_distribution(unsigned r, unsigned n, unsigned N); // r=defective/failures/success, n=trials/draws, N=total population.
// Accessors:
unsigned total()const;
unsigned defective()const;
@@ -73,6 +73,15 @@ Returns the number of objects /r/ in population /N/ which are defective.
Returns the number of objects /n/ which are sampled from the population /N/.
[warning Both naming/symbol and order of parameters is confusing with no two implementations the same!
See Wolfram Mathematica
[@https://mathworld.wolfram.com/HypergeometricDistribution.html Hypergeometric Distribution]
and Wikipedia
[@https://en.wikipedia.org/wiki/Hypergeometric_distribution Hypergeometric Distribution]
and Python
[@https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.hypergeom.html#scipy.stats.hypergeom scipy.stats.hypergeom].
]
[h4 Non-member Accessors]
All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions]
@@ -137,6 +146,9 @@ our implementation against some spot values computed using the online calculator
here [@http://stattrek.com/Tables/Hypergeometric.aspx http://stattrek.com/Tables/Hypergeometric.aspx].
Finally we test accuracy against some high precision test data using
this implementation and NTL::RR.
Spot test values for moments (mean to kurtosis) are from Mathematica [@https://mathworld.wolfram.com/HypergeometricDistribution.html Hypergeometric Distribution]
and agree with an implementation of Wikipedia [@https://en.wikipedia.org/wiki/Hypergeometric_distribution Hypergeometric Distribution]
and Python [@https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.hypergeom.html#scipy.stats.hypergeom scipy.stats.hypergeom].
[h4 Implementation]
@@ -198,7 +210,7 @@ lgamma. However, in this area where N > 104729, the user should expect
to lose around log[sub 10]N decimal digits during the calculation in
the worst case.
The CDF and its complement is calculated by directly summing the PDF's.
The CDF and its complement is calculated by directly summing the PDFs.
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 /k/ (or /k+1/ if we're
calculating the complement) and calculate successive PDF values via the
@@ -219,6 +231,16 @@ calculated via:
[equation hypergeometric6]
[note The kurtosis formula above is not quite correct and kurtosis excess is now calculated
from
[@https://www.wolframalpha.com/input/?i=kurtosis+hypergeometric+distribution Wolfram Alpha hypergeometric distribution kurtosis].
(The hypergeometric distribution kurtosis excess is mentioned in
[@https://mathworld.wolfram.com/HypergeometricDistribution.html Wolfram Hypergeometric distribution]
but coyly only described as ['\"the kurtosis excess is given by a complicated expression.\"]).
This has been found numerically equivalent to the
[@https://en.wikipedia.org/wiki/Hypergeometric_distribution Wikipedia hypergeometric kurtosis excess formula].
]
[endsect]
[/ hypergeometric.qbk

View File

@@ -134,7 +134,7 @@ This manual is also available in <a href="http://sourceforge.net/projects/boost/
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: March 30, 2021 at 17:44:57 GMT</small></p></td>
<td align="left"><p><small>Last revised: June 16, 2021 at 10:35:24 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>

View File

@@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id2044616"></a>Function Index</h2></div></div></div>
<a name="id2124353"></a>Function Index</h2></div></div></div>
<p><a class="link" href="s01.html#idx_id_0">1</a> <a class="link" href="s01.html#idx_id_1">2</a> <a class="link" href="s01.html#idx_id_2">4</a> <a class="link" href="s01.html#idx_id_5">A</a> <a class="link" href="s01.html#idx_id_6">B</a> <a class="link" href="s01.html#idx_id_7">C</a> <a class="link" href="s01.html#idx_id_8">D</a> <a class="link" href="s01.html#idx_id_9">E</a> <a class="link" href="s01.html#idx_id_10">F</a> <a class="link" href="s01.html#idx_id_11">G</a> <a class="link" href="s01.html#idx_id_12">H</a> <a class="link" href="s01.html#idx_id_13">I</a> <a class="link" href="s01.html#idx_id_14">J</a> <a class="link" href="s01.html#idx_id_15">K</a> <a class="link" href="s01.html#idx_id_16">L</a> <a class="link" href="s01.html#idx_id_17">M</a> <a class="link" href="s01.html#idx_id_18">N</a> <a class="link" href="s01.html#idx_id_19">O</a> <a class="link" href="s01.html#idx_id_20">P</a> <a class="link" href="s01.html#idx_id_21">Q</a> <a class="link" href="s01.html#idx_id_22">R</a> <a class="link" href="s01.html#idx_id_23">S</a> <a class="link" href="s01.html#idx_id_24">T</a> <a class="link" href="s01.html#idx_id_25">U</a> <a class="link" href="s01.html#idx_id_26">V</a> <a class="link" href="s01.html#idx_id_27">W</a> <a class="link" href="s01.html#idx_id_28">X</a> <a class="link" href="s01.html#idx_id_29">Y</a> <a class="link" href="s01.html#idx_id_30">Z</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
@@ -2502,6 +2502,10 @@
</ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">means</span></p>
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/stat_tut/weg/f_eg.html" title="F Distribution Examples"><span class="index-entry-level-1">F Distribution Examples</span></a></p></li></ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">means_and_covariance</span></p>
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/bivariate_statistics.html" title="Bivariate Statistics"><span class="index-entry-level-1">Bivariate Statistics</span></a></p></li></ul></div>
</li>

View File

@@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id2074069"></a>Class Index</h2></div></div></div>
<a name="id2155303"></a>Class Index</h2></div></div></div>
<p><a class="link" href="s02.html#idx_id_36">A</a> <a class="link" href="s02.html#idx_id_37">B</a> <a class="link" href="s02.html#idx_id_38">C</a> <a class="link" href="s02.html#idx_id_39">D</a> <a class="link" href="s02.html#idx_id_40">E</a> <a class="link" href="s02.html#idx_id_41">F</a> <a class="link" href="s02.html#idx_id_42">G</a> <a class="link" href="s02.html#idx_id_43">H</a> <a class="link" href="s02.html#idx_id_44">I</a> <a class="link" href="s02.html#idx_id_46">K</a> <a class="link" href="s02.html#idx_id_47">L</a> <a class="link" href="s02.html#idx_id_48">M</a> <a class="link" href="s02.html#idx_id_49">N</a> <a class="link" href="s02.html#idx_id_50">O</a> <a class="link" href="s02.html#idx_id_51">P</a> <a class="link" href="s02.html#idx_id_52">Q</a> <a class="link" href="s02.html#idx_id_53">R</a> <a class="link" href="s02.html#idx_id_54">S</a> <a class="link" href="s02.html#idx_id_55">T</a> <a class="link" href="s02.html#idx_id_56">U</a> <a class="link" href="s02.html#idx_id_57">V</a> <a class="link" href="s02.html#idx_id_58">W</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>

View File

@@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id2077418"></a>Typedef Index</h2></div></div></div>
<a name="id2159548"></a>Typedef Index</h2></div></div></div>
<p><a class="link" href="s03.html#idx_id_67">A</a> <a class="link" href="s03.html#idx_id_68">B</a> <a class="link" href="s03.html#idx_id_69">C</a> <a class="link" href="s03.html#idx_id_70">D</a> <a class="link" href="s03.html#idx_id_71">E</a> <a class="link" href="s03.html#idx_id_72">F</a> <a class="link" href="s03.html#idx_id_73">G</a> <a class="link" href="s03.html#idx_id_74">H</a> <a class="link" href="s03.html#idx_id_75">I</a> <a class="link" href="s03.html#idx_id_77">K</a> <a class="link" href="s03.html#idx_id_78">L</a> <a class="link" href="s03.html#idx_id_80">N</a> <a class="link" href="s03.html#idx_id_82">P</a> <a class="link" href="s03.html#idx_id_84">R</a> <a class="link" href="s03.html#idx_id_85">S</a> <a class="link" href="s03.html#idx_id_86">T</a> <a class="link" href="s03.html#idx_id_87">U</a> <a class="link" href="s03.html#idx_id_88">V</a> <a class="link" href="s03.html#idx_id_89">W</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>

View File

@@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id2080450"></a>Macro Index</h2></div></div></div>
<a name="id2161564"></a>Macro Index</h2></div></div></div>
<p><a class="link" href="s04.html#idx_id_99">B</a> <a class="link" href="s04.html#idx_id_103">F</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
@@ -305,6 +305,13 @@
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/config_macros.html#math_toolkit.config_macros.boost_math_macros" title="Table 1.11. Boost.Math Macros"><span class="index-entry-level-1">Boost.Math Macros</span></a></p></li></ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">BOOST_MATH_STANDALONE</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/error_handling.html" title="Error Handling"><span class="index-entry-level-1">Error Handling</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/special_tut/special_tut_test.html" title="Testing"><span class="index-entry-level-1">Testing</span></a></p></li>
</ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">BOOST_MATH_STD_USING</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/config_macros.html#math_toolkit.config_macros.boost_math_macros" title="Table 1.11. Boost.Math Macros"><span class="index-entry-level-1">Boost.Math Macros</span></a></p></li>
@@ -328,6 +335,14 @@
<p><span class="index-entry-level-0">BOOST_MATH_USE_FLOAT128</span></p>
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/config_macros.html#math_toolkit.config_macros.boost_math_macros" title="Table 1.11. Boost.Math Macros"><span class="index-entry-level-1">Boost.Math Macros</span></a></p></li></ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">BOOST_STRINGIZE</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/pol_tutorial/changing_policy_defaults.html" title="Changing the Policy Defaults"><span class="index-entry-level-1">Changing the Policy Defaults</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/stat_tut/weg/error_eg.html" title="Error Handling Example"><span class="index-entry-level-1">Error Handling Example</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/test_data.html" title="Graphing, Profiling, and Generating Test Data for Special Functions"><span class="index-entry-level-1">Graphing, Profiling, and Generating Test Data for Special Functions</span></a></p></li>
</ul></div>
</li>
</ul></div></dd>
<dt>
<a name="idx_id_103"></a><span class="term">F</span>

View File

@@ -23,7 +23,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id2079680"></a>Index</h2></div></div></div>
<a name="id2163136"></a>Index</h2></div></div></div>
<p><a class="link" href="s05.html#idx_id_124">1</a> <a class="link" href="s05.html#idx_id_125">2</a> <a class="link" href="s05.html#idx_id_126">4</a> <a class="link" href="s05.html#idx_id_127">5</a> <a class="link" href="s05.html#idx_id_128">7</a> <a class="link" href="s05.html#idx_id_129">A</a> <a class="link" href="s05.html#idx_id_130">B</a> <a class="link" href="s05.html#idx_id_131">C</a> <a class="link" href="s05.html#idx_id_132">D</a> <a class="link" href="s05.html#idx_id_133">E</a> <a class="link" href="s05.html#idx_id_134">F</a> <a class="link" href="s05.html#idx_id_135">G</a> <a class="link" href="s05.html#idx_id_136">H</a> <a class="link" href="s05.html#idx_id_137">I</a> <a class="link" href="s05.html#idx_id_138">J</a> <a class="link" href="s05.html#idx_id_139">K</a> <a class="link" href="s05.html#idx_id_140">L</a> <a class="link" href="s05.html#idx_id_141">M</a> <a class="link" href="s05.html#idx_id_142">N</a> <a class="link" href="s05.html#idx_id_143">O</a> <a class="link" href="s05.html#idx_id_144">P</a> <a class="link" href="s05.html#idx_id_145">Q</a> <a class="link" href="s05.html#idx_id_146">R</a> <a class="link" href="s05.html#idx_id_147">S</a> <a class="link" href="s05.html#idx_id_148">T</a> <a class="link" href="s05.html#idx_id_149">U</a> <a class="link" href="s05.html#idx_id_150">V</a> <a class="link" href="s05.html#idx_id_151">W</a> <a class="link" href="s05.html#idx_id_152">X</a> <a class="link" href="s05.html#idx_id_153">Y</a> <a class="link" href="s05.html#idx_id_154">Z</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
@@ -1218,6 +1218,13 @@
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/config_macros.html#math_toolkit.config_macros.boost_math_macros" title="Table 1.11. Boost.Math Macros"><span class="index-entry-level-1">Boost.Math Macros</span></a></p></li></ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">BOOST_MATH_STANDALONE</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/error_handling.html" title="Error Handling"><span class="index-entry-level-1">Error Handling</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/special_tut/special_tut_test.html" title="Testing"><span class="index-entry-level-1">Testing</span></a></p></li>
</ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">BOOST_MATH_STD_USING</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/config_macros.html#math_toolkit.config_macros.boost_math_macros" title="Table 1.11. Boost.Math Macros"><span class="index-entry-level-1">Boost.Math Macros</span></a></p></li>
@@ -1241,6 +1248,14 @@
<p><span class="index-entry-level-0">BOOST_MATH_USE_FLOAT128</span></p>
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/config_macros.html#math_toolkit.config_macros.boost_math_macros" title="Table 1.11. Boost.Math Macros"><span class="index-entry-level-1">Boost.Math Macros</span></a></p></li></ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">BOOST_STRINGIZE</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/pol_tutorial/changing_policy_defaults.html" title="Changing the Policy Defaults"><span class="index-entry-level-1">Changing the Policy Defaults</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/stat_tut/weg/error_eg.html" title="Error Handling Example"><span class="index-entry-level-1">Error Handling Example</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/test_data.html" title="Graphing, Profiling, and Generating Test Data for Special Functions"><span class="index-entry-level-1">Graphing, Profiling, and Generating Test Data for Special Functions</span></a></p></li>
</ul></div>
</li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/roots_noderiv/bracket_solve.html" title="Bracket and Solve Root"><span class="index-entry-level-0">Bracket and Solve Root</span></a></p></li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">bracket_and_solve_root</span></p>
@@ -2019,6 +2034,7 @@
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/pol_tutorial/changing_policy_defaults.html" title="Changing the Policy Defaults"><span class="index-entry-level-1">BOOST_MATH_ASSERT_UNDEFINED_POLICY</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/pol_tutorial/changing_policy_defaults.html" title="Changing the Policy Defaults"><span class="index-entry-level-1">BOOST_MATH_DOMAIN_ERROR_POLICY</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/pol_tutorial/changing_policy_defaults.html" title="Changing the Policy Defaults"><span class="index-entry-level-1">BOOST_MATH_OVERFLOW_ERROR_POLICY</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/pol_tutorial/changing_policy_defaults.html" title="Changing the Policy Defaults"><span class="index-entry-level-1">BOOST_STRINGIZE</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/pol_tutorial/changing_policy_defaults.html" title="Changing the Policy Defaults"><span class="index-entry-level-1">distribution</span></a></p></li>
</ul></div>
</li>
@@ -3485,6 +3501,7 @@
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">Error Handling</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/error_handling.html" title="Error Handling"><span class="index-entry-level-1">BOOST_MATH_STANDALONE</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/error_handling.html" title="Error Handling"><span class="index-entry-level-1">checked_narrowing_cast</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/error_handling.html" title="Error Handling"><span class="index-entry-level-1">feedback</span></a></p></li>
</ul></div>
@@ -3494,6 +3511,7 @@
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/stat_tut/weg/error_eg.html" title="Error Handling Example"><span class="index-entry-level-1">BOOST_MATH_DOMAIN_ERROR_POLICY</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/stat_tut/weg/error_eg.html" title="Error Handling Example"><span class="index-entry-level-1">BOOST_MATH_OVERFLOW_ERROR_POLICY</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/stat_tut/weg/error_eg.html" title="Error Handling Example"><span class="index-entry-level-1">BOOST_STRINGIZE</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/stat_tut/weg/error_eg.html" title="Error Handling Example"><span class="index-entry-level-1">infinity</span></a></p></li>
</ul></div>
</li>
@@ -4214,6 +4232,10 @@
</ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">F Distribution Examples</span></p>
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/stat_tut/weg/f_eg.html" title="F Distribution Examples"><span class="index-entry-level-1">means</span></a></p></li></ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">Facets for Floating-Point Infinities and NaNs</span></p>
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/fp_facets.html" title="Facets for Floating-Point Infinities and NaNs"><span class="index-entry-level-1">nonfinite_num_get</span></a></p></li>
@@ -4934,6 +4956,7 @@
<div class="index"><ul class="index" style="list-style-type: none; ">
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/test_data.html" title="Graphing, Profiling, and Generating Test Data for Special Functions"><span class="index-entry-level-1">accuracy</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/test_data.html" title="Graphing, Profiling, and Generating Test Data for Special Functions"><span class="index-entry-level-1">BOOST_JOIN</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/test_data.html" title="Graphing, Profiling, and Generating Test Data for Special Functions"><span class="index-entry-level-1">BOOST_STRINGIZE</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/test_data.html" title="Graphing, Profiling, and Generating Test Data for Special Functions"><span class="index-entry-level-1">directory</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/test_data.html" title="Graphing, Profiling, and Generating Test Data for Special Functions"><span class="index-entry-level-1">operator</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/internals/test_data.html" title="Graphing, Profiling, and Generating Test Data for Special Functions"><span class="index-entry-level-1">size</span></a></p></li>
@@ -6747,6 +6770,10 @@
</ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">means</span></p>
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/stat_tut/weg/f_eg.html" title="F Distribution Examples"><span class="index-entry-level-1">F Distribution Examples</span></a></p></li></ul></div>
</li>
<li class="listitem" style="list-style-type: none">
<p><span class="index-entry-level-0">means_and_covariance</span></p>
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/bivariate_statistics.html" title="Bivariate Statistics"><span class="index-entry-level-1">Bivariate Statistics</span></a></p></li></ul></div>
</li>
@@ -9083,6 +9110,7 @@
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/special_tut/special_tut_test.html" title="Testing"><span class="index-entry-level-1">BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/special_tut/special_tut_test.html" title="Testing"><span class="index-entry-level-1">BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/special_tut/special_tut_test.html" title="Testing"><span class="index-entry-level-1">BOOST_MATH_NO_REAL_CONCEPT_TESTS</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/special_tut/special_tut_test.html" title="Testing"><span class="index-entry-level-1">BOOST_MATH_STANDALONE</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/special_tut/special_tut_test.html" title="Testing"><span class="index-entry-level-1">bug</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/special_tut/special_tut_test.html" title="Testing"><span class="index-entry-level-1">constants</span></a></p></li>
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../math_toolkit/special_tut/special_tut_test.html" title="Testing"><span class="index-entry-level-1">cpp_dec_float</span></a></p></li>

View File

@@ -32,7 +32,7 @@
</h4>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">interpolators</span><span class="special">/</span><span class="identifier">barycentric_rational</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<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">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">namespace</span> <span class="identifier">interpolators</span><span class="special">{</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Real</span><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">barycentric_rational</span>
<span class="special">{</span>
@@ -53,7 +53,7 @@
<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">&gt;&amp;&amp;</span> <span class="identifier">return_y</span><span class="special">();</span>
<span class="special">};</span>
<span class="special">}}</span>
<span class="special">}}}</span>
</pre>
<h4>
<a name="math_toolkit.barycentric.h1"></a>
@@ -78,7 +78,7 @@
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">x</span><span class="special">(</span><span class="number">500</span><span class="special">);</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">y</span><span class="special">(</span><span class="number">500</span><span class="special">);</span>
<span class="comment">// populate x, y, then:</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">barycentric_rational</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">interpolant</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(</span><span class="identifier">x</span><span class="special">),</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(</span><span class="identifier">y</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">interpolators</span><span class="special">::</span><span class="identifier">barycentric_rational</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">interpolant</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(</span><span class="identifier">x</span><span class="special">),</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(</span><span class="identifier">y</span><span class="special">));</span>
</pre>
<p>
This implicitly calls the constructor with approximation order 3, and hence
@@ -87,7 +87,7 @@
A call to the constructor with an explicit approximation order is demonstrated
below
</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">barycentric_rational</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">interpolant</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(</span><span class="identifier">x</span><span class="special">),</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(</span><span class="identifier">y</span><span class="special">),</span> <span class="number">5</span><span class="special">);</span>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">interpolators</span><span class="special">::</span><span class="identifier">barycentric_rational</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">interpolant</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(</span><span class="identifier">x</span><span class="special">),</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(</span><span class="identifier">y</span><span class="special">),</span> <span class="number">5</span><span class="special">);</span>
</pre>
<p>
To evaluate the interpolant, simply use
@@ -168,7 +168,7 @@
<span class="comment">// We'll skip the code for filling the above vectors with data for now...</span>
<span class="comment">// Now we want to interpolate this potential at any r:</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">barycentric_rational</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">b</span><span class="special">(</span><span class="identifier">r</span><span class="special">.</span><span class="identifier">data</span><span class="special">(),</span> <span class="identifier">mrV</span><span class="special">.</span><span class="identifier">data</span><span class="special">(),</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">size</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">interpolators</span><span class="special">::</span><span class="identifier">barycentric_rational</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">b</span><span class="special">(</span><span class="identifier">r</span><span class="special">.</span><span class="identifier">data</span><span class="special">(),</span> <span class="identifier">mrV</span><span class="special">.</span><span class="identifier">data</span><span class="special">(),</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">size</span><span class="special">());</span>
<span class="keyword">for</span> <span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">8</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
@@ -242,7 +242,7 @@
<span class="comment">// start by creating 2 ranges for the x and y values:</span>
<span class="keyword">auto</span> <span class="identifier">x_range</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">adaptors</span><span class="special">::</span><span class="identifier">keys</span><span class="special">(</span><span class="identifier">r</span><span class="special">);</span>
<span class="keyword">auto</span> <span class="identifier">y_range</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">adaptors</span><span class="special">::</span><span class="identifier">values</span><span class="special">(</span><span class="identifier">r</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">barycentric_rational</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">b</span><span class="special">(</span><span class="identifier">x_range</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">x_range</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">y_range</span><span class="special">.</span><span class="identifier">begin</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">interpolators</span><span class="special">::</span><span class="identifier">barycentric_rational</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">b</span><span class="special">(</span><span class="identifier">x_range</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">x_range</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">y_range</span><span class="special">.</span><span class="identifier">begin</span><span class="special">());</span>
<span class="comment">//</span>
<span class="comment">// We'll use a lambda expression to provide the functor to our root finder, since we want</span>
<span class="comment">// the abscissa value that yields 3, not zero. We pass the functor b by value to the</span>

View File

@@ -27,7 +27,7 @@
<a name="math_toolkit.conventions"></a><a class="link" href="conventions.html" title="Document Conventions">Document Conventions</a>
</h2></div></div></div>
<p>
<a class="indexterm" name="id957356"></a>
<a class="indexterm" name="id1028641"></a>
</p>
<p>
This documentation aims to use of the following naming and formatting conventions.

View File

@@ -41,7 +41,7 @@
<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="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">// r=defective/failures/success, n=trials/draws, N=total population.</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>
@@ -128,6 +128,18 @@
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>
<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>
Both naming/symbol and order of parameters is confusing with no two implementations
the same! See Wolfram Mathematica <a href="https://mathworld.wolfram.com/HypergeometricDistribution.html" target="_top">Hypergeometric
Distribution</a> and Wikipedia <a href="https://en.wikipedia.org/wiki/Hypergeometric_distribution" target="_top">Hypergeometric
Distribution</a> and Python <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.hypergeom.html#scipy.stats.hypergeom" target="_top">scipy.stats.hypergeom</a>.
</p></td></tr>
</table></div>
<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
@@ -218,7 +230,10 @@
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.
implementation and NTL::RR. Spot test values for moments (mean to kurtosis)
are from Mathematica <a href="https://mathworld.wolfram.com/HypergeometricDistribution.html" target="_top">Hypergeometric
Distribution</a> and agree with an implementation of Wikipedia <a href="https://en.wikipedia.org/wiki/Hypergeometric_distribution" target="_top">Hypergeometric
Distribution</a> and Python <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.hypergeom.html#scipy.stats.hypergeom" target="_top">scipy.stats.hypergeom</a>.
</p>
<h5>
<a name="math_toolkit.dist_ref.dists.hypergeometric_dist.h4"></a>
@@ -299,7 +314,7 @@
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.
The CDF and its complement is calculated by directly summing the PDFs.
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
@@ -327,6 +342,22 @@
<span class="inlinemediaobject"><img src="../../../../equations/hypergeometric6.svg"></span>
</p></blockquote></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>
The kurtosis formula above is not quite correct and kurtosis excess is
now calculated from <a href="https://www.wolframalpha.com/input/?i=kurtosis+hypergeometric+distribution" target="_top">Wolfram
Alpha hypergeometric distribution kurtosis</a>. (The hypergeometric
distribution kurtosis excess is mentioned in <a href="https://mathworld.wolfram.com/HypergeometricDistribution.html" target="_top">Wolfram
Hypergeometric distribution</a> but coyly only described as <span class="emphasis"><em>"the
kurtosis excess is given by a complicated expression."</em></span>).
This has been found numerically equivalent to the <a href="https://en.wikipedia.org/wiki/Hypergeometric_distribution" target="_top">Wikipedia
hypergeometric kurtosis excess formula</a>.
</p></td></tr>
</table></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>

View File

@@ -27,7 +27,7 @@
<a name="math_toolkit.navigation"></a><a class="link" href="navigation.html" title="Navigation">Navigation</a>
</h2></div></div></div>
<p>
<a class="indexterm" name="id957207"></a>
<a class="indexterm" name="id1028515"></a>
</p>
<p>
Boost.Math documentation is provided in both HTML and PDF formats.

View File

@@ -275,7 +275,9 @@ readers will have to refer to the code for the transitions between methods, as w
In almost all cases where /z < 0/ we use [@https://en.wikipedia.org/wiki/Confluent_hypergeometric_function Kummer's relation]
to make /z/ positive:
[:[/\large $$_1F_1(a, b; -z) = e^{-z} {_1F_1}(a, b; z)$$]
[:[/\large $$_1F_1(a, b; -z) = e^{-z} {_1F_1}(b-a, b; z)$$]
[/ https://github.com/boostorg/math/issues/638]
[/See https://dlmf.nist.gov/13.2#E39]
[$../equations/hypergeometric_1f1_12.svg]]
The main series representation
@@ -532,4 +534,4 @@ error inherent in calculating the N'th term via logarithms.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
]
]

View File

@@ -1,5 +1,6 @@
// Copyright 2008 Gautam Sewani
// Copyright 2008 John Maddock
// Copyright 2021 Paul A. Bristow
//
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0.
@@ -16,7 +17,6 @@
#include <boost/math/distributions/detail/hypergeometric_quantile.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
namespace boost { namespace math {
template <class RealType = double, class Policy = policies::policy<> >
@@ -26,7 +26,7 @@ namespace boost { namespace math {
typedef RealType value_type;
typedef Policy policy_type;
hypergeometric_distribution(unsigned r, unsigned n, unsigned N) // Constructor.
hypergeometric_distribution(unsigned r, unsigned n, unsigned N) // Constructor. r=defective/failures/success, n=trials/draws, N=total population.
: m_n(n), m_N(N), m_r(r)
{
static const char* function = "boost::math::hypergeometric_distribution<%1%>::hypergeometric_distribution";
@@ -39,7 +39,7 @@ namespace boost { namespace math {
return m_N;
}
unsigned defective()const
unsigned defective()const // successes/failures/events
{
return m_r;
}
@@ -84,9 +84,9 @@ namespace boost { namespace math {
private:
// Data members:
unsigned m_n; // number of items picked
unsigned m_N; // number of "total" items
unsigned m_r; // number of "defective" items
unsigned m_n; // number of items picked or drawn.
unsigned m_N; // number of "total" items.
unsigned m_r; // number of "defective/successes/failures/events items.
}; // class hypergeometric_distribution
@@ -231,6 +231,8 @@ namespace boost { namespace math {
return static_cast<RealType>(detail::hypergeometric_quantile(RealType(1 - c.param), c.param, c.dist.defective(), c.dist.sample_count(), c.dist.total(), Policy()));
} // quantile
// https://www.wolframalpha.com/input/?i=kurtosis+hypergeometric+distribution
template <class RealType, class Policy>
inline RealType mean(const hypergeometric_distribution<RealType, Policy>& dist)
{
@@ -269,13 +271,23 @@ namespace boost { namespace math {
template <class RealType, class Policy>
inline RealType kurtosis_excess(const hypergeometric_distribution<RealType, Policy>& dist)
{
RealType r = static_cast<RealType>(dist.defective());
RealType n = static_cast<RealType>(dist.sample_count());
RealType N = static_cast<RealType>(dist.total());
RealType t1 = N * N * (N - 1) / (r * (N - 2) * (N - 3) * (N - r));
RealType t2 = (N * (N + 1) - 6 * N * (N - r)) / (n * (N - n))
+ 3 * r * (N - r) * (N + 6) / (N * N) - 6;
return t1 * t2;
// https://www.wolframalpha.com/input/?i=kurtosis+hypergeometric+distribution shown as plain text:
// mean | (m n)/N
// standard deviation | sqrt((m n(N - m) (N - n))/(N - 1))/N
// variance | (m n(1 - m/N) (N - n))/((N - 1) N)
// skewness | (sqrt(N - 1) (N - 2 m) (N - 2 n))/((N - 2) sqrt(m n(N - m) (N - n)))
// kurtosis | ((N - 1) N^2 ((3 m(N - m) (n^2 (-N) + (n - 2) N^2 + 6 n(N - n)))/N^2 - 6 n(N - n) + N(N + 1)))/(m n(N - 3) (N - 2) (N - m) (N - n))
// Kurtosis[HypergeometricDistribution[n, m, N]]
RealType m = static_cast<RealType>(dist.defective()); // Failures or success events. (Also symbols K or M are used).
RealType n = static_cast<RealType>(dist.sample_count()); // draws or trials.
RealType n2 = n * n; // n^2
RealType N = static_cast<RealType>(dist.total()); // Total population from which n draws or trials are made.
RealType N2 = N * N; // N^2
// result = ((N - 1) N^2 ((3 m(N - m) (n^2 (-N) + (n - 2) N^2 + 6 n(N - n)))/N^2 - 6 n(N - n) + N(N + 1)))/(m n(N - 3) (N - 2) (N - m) (N - n));
RealType result = ((N-1)*N2*((3*m*(N-m)*(n2*(-N)+(n-2)*N2+6*n*(N-n)))/N2-6*n*(N-n)+N*(N+1)))/(m*n*(N-3)*(N-2)*(N-m)*(N-n));
// Agrees with kurtosis hypergeometric distribution(50,200,500) kurtosis = 2.96917
// N[kurtosis[hypergeometricdistribution(50,200,500)], 55] 2.969174035736058474901169623721804275002985337280263464
return result;
} // RealType kurtosis_excess(const hypergeometric_distribution<RealType, Policy>& dist)
template <class RealType, class Policy>

View File

@@ -1,22 +0,0 @@
// Copyright John Maddock 2018
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// This test file exists to output diagnostic info for tests failing in the online matrix
// for perplexing reasons, it's contents are subject to constant change!!
//
#define BOOST_MATH_INSTRUMENT
#include <boost/math/special_functions/math_fwd.hpp>
#include <iostream>
int main()
{
std::cout << "EllintD(1, -1) = " << std::setprecision(20) << boost::math::ellint_d(1.0, -1.0) << std::endl;
std::cout << "EllintD(6.4851474761962890625e-01L , -7.6733188629150390625e+00L) = " << std::setprecision(20) << boost::math::ellint_d(6.4851474761962890625e-01, -7.6733188629150390625e+00) << std::endl;
std::cout << "EllintD(1, -1) = " << std::setprecision(20) << boost::math::ellint_d(1.0L, -1.0L) << std::endl;
std::cout << "EllintD(6.4851474761962890625e-01L , -7.6733188629150390625e+00L) = " << std::setprecision(20) << boost::math::ellint_d(6.4851474761962890625e-01L , -7.6733188629150390625e+00L) << std::endl;
}

View File

@@ -1,6 +1,6 @@
// Copyright John Maddock 2008
// Copyright Paul A. Bristow
// Copyright Gautam Sewani
// Copyright Paul A. Bristow 2021
// Copyright Gautam Sewani 2008
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0.
@@ -165,8 +165,8 @@ void do_test_hypergeometric(const T& data, const char* type_name, const char* te
// test hypergeometric against data:
//
result = boost::math::tools::test_hetero<Real>(
data,
bind_func<Real>(funcp, 0, 1, 2, 3),
data,
bind_func<Real>(funcp, 0, 1, 2, 3),
extract_result<Real>(4));
handle_test_result(result, data[result.worst()], result.worst(), type_name, "hypergeometric PDF", test_name);
@@ -180,8 +180,8 @@ void do_test_hypergeometric(const T& data, const char* type_name, const char* te
// test hypergeometric against data:
//
result = boost::math::tools::test_hetero<Real>(
data,
bind_func<Real>(funcp, 0, 1, 2, 3),
data,
bind_func<Real>(funcp, 0, 1, 2, 3),
extract_result<Real>(5));
handle_test_result(result, data[result.worst()], result.worst(), type_name, "hypergeometric CDF", test_name);
@@ -195,8 +195,8 @@ void do_test_hypergeometric(const T& data, const char* type_name, const char* te
// test hypergeometric against data:
//
result = boost::math::tools::test_hetero<Real>(
data,
bind_func<Real>(funcp, 0, 1, 2, 3),
data,
bind_func<Real>(funcp, 0, 1, 2, 3),
extract_result<Real>(6));
handle_test_result(result, data[result.worst()], result.worst(), type_name, "hypergeometric CDF complement", test_name);
std::cout << std::endl;
@@ -234,7 +234,7 @@ void do_test_hypergeometric_quantile(const T& data, const char* type_name, const
(void)ccp;
#if !defined(TEST_QUANT) || (TEST_QUANT == 1)
boost::math::hypergeometric_distribution<value_type,
boost::math::hypergeometric_distribution<value_type,
policy<discrete_quantile<integer_round_up> > > du(r, n, N);
if((cp < 0.9) && (cp > boost::math::tools::min_value<value_type>()))
@@ -247,7 +247,7 @@ void do_test_hypergeometric_quantile(const T& data, const char* type_name, const
}
#endif
#if !defined(TEST_QUANT) || (TEST_QUANT == 2)
boost::math::hypergeometric_distribution<value_type,
boost::math::hypergeometric_distribution<value_type,
policy<discrete_quantile<integer_round_down> > > dl(r, n, N);
if((cp < 0.9) && (cp > boost::math::tools::min_value<value_type>()))
{
@@ -259,7 +259,7 @@ void do_test_hypergeometric_quantile(const T& data, const char* type_name, const
}
#endif
#if !defined(TEST_QUANT) || (TEST_QUANT == 3)
boost::math::hypergeometric_distribution<value_type,
boost::math::hypergeometric_distribution<value_type,
policy<discrete_quantile<integer_round_nearest> > > dn(r, n, N);
if((cp < 0.9) && (cp > boost::math::tools::min_value<value_type>()))
@@ -272,7 +272,7 @@ void do_test_hypergeometric_quantile(const T& data, const char* type_name, const
}
#endif
#if !defined(TEST_QUANT) || (TEST_QUANT == 4)
boost::math::hypergeometric_distribution<value_type,
boost::math::hypergeometric_distribution<value_type,
policy<discrete_quantile<integer_round_outwards> > > dou(r, n, N);
if((cp < 0.9) && (cp > boost::math::tools::min_value<value_type>()))
@@ -299,7 +299,7 @@ void do_test_hypergeometric_quantile(const T& data, const char* type_name, const
}
#endif
#if !defined(TEST_QUANT) || (TEST_QUANT == 5)
boost::math::hypergeometric_distribution<value_type,
boost::math::hypergeometric_distribution<value_type,
policy<discrete_quantile<integer_round_inwards> > > di(r, n, N);
if((cp < 0.9) && (cp > boost::math::tools::min_value<value_type>()))
@@ -331,7 +331,7 @@ void do_test_hypergeometric_quantile(const T& data, const char* type_name, const
template <class RealType>
void test_spot(unsigned x, unsigned n, unsigned r, unsigned N,
void test_spot(unsigned x, unsigned n, unsigned r, unsigned N,
RealType p, RealType cp, RealType ccp, RealType tol)
{
//
@@ -366,18 +366,18 @@ void test_spot(unsigned x, unsigned n, unsigned r, unsigned N,
{
using namespace boost::math::policies;
boost::math::hypergeometric_distribution<RealType,
boost::math::hypergeometric_distribution<RealType,
policy<discrete_quantile<integer_round_up> > > du(r, n, N);
BOOST_CHECK_EX(quantile(du, cp) >= x);
BOOST_CHECK_EX(quantile(complement(du, ccp)) >= x);
boost::math::hypergeometric_distribution<RealType,
boost::math::hypergeometric_distribution<RealType,
policy<discrete_quantile<integer_round_down> > > dl(r, n, N);
BOOST_CHECK_EX(quantile(dl, cp) <= x);
BOOST_CHECK_EX(quantile(complement(dl, ccp)) <= x);
boost::math::hypergeometric_distribution<RealType,
boost::math::hypergeometric_distribution<RealType,
policy<discrete_quantile<integer_round_nearest> > > dn(r, n, N);
BOOST_CHECK_EX(quantile(dn, cp) == x);
@@ -443,7 +443,7 @@ void test_spots(RealType /*T*/, const char* type_name)
static_cast<RealType>(2e-16L), // limit of test data
boost::math::tools::epsilon<RealType>());
cout<<"Absolute tolerance:"<<tolerance<<endl;
tolerance *= 50 * 100; // 50eps as a percentage
cout << "Tolerance for type " << typeid(RealType).name() << " is " << tolerance << " %" << endl;
@@ -466,9 +466,17 @@ void test_spots(RealType /*T*/, const char* type_name)
BOOST_CHECK_EQUAL(range(d).second, 50u);
BOOST_CHECK_CLOSE(mean(d), static_cast<RealType>(20), tolerance);
BOOST_CHECK_CLOSE(mode(d), static_cast<RealType>(20), tolerance);
BOOST_CHECK_CLOSE(variance(d), static_cast<RealType>(10.821643286573146292585170340681L), tolerance);
BOOST_CHECK_CLOSE(skewness(d), static_cast<RealType>(0.048833071022952084732902910189366L), tolerance);
BOOST_CHECK_CLOSE(kurtosis_excess(d), static_cast<RealType>(2.5155486690782804816404001878293L), tolerance);
// Test values and code revised to correct kurtosis using Mathematica algorithm and test values.
// Also checked using boost::multiprecision::cpp_bin_float_quad at 128-bit precision.
// And compared to an implementation of the Wikipedia equation at https://en.wikipedia.org/wiki/Hypergeometric_distribution.
// https://github.com/boostorg/math/issues/639 hypergeometric kurtosis differs from Wolfram and scipy and Wikipedia.
// N[variance[hypergeometricdistribution(200,50,500)], 55]
BOOST_CHECK_CLOSE(variance(d), static_cast<RealType>(10.82164328657314629258517034068136272545090180360721443L), tolerance);
// N[skewness[hypergeometricdistribution(200,50,500)], 55]
BOOST_CHECK_CLOSE(skewness(d), static_cast<RealType>(0.04883307102295208473290291018936563084537649911337978351L), tolerance);
// https://www.wolframalpha.com/input/?i=N%5Bkurtosis%5Bhypergeometricdistribution%28200%2C50%2C500%29%5D%2C+55%5D+
// N[kurtosis[hypergeometricdistribution(200,50,500)], 55] = 2.969174035736058474901169623721804275002985337280263464
BOOST_CHECK_CLOSE(kurtosis_excess(d), static_cast<RealType>(2.969174035736058474901169623721804275002985337280263464L), tolerance);
BOOST_CHECK_CLOSE(kurtosis(d), kurtosis_excess(d) + 3, tolerance);
BOOST_CHECK_EQUAL(quantile(d, 0.5f), median(d));
@@ -496,6 +504,6 @@ BOOST_AUTO_TEST_CASE( test_main )
"to pass.</note>" << std::endl;
#endif
} // BOOST_AUTO_TEST_CASE( test_main )