Boost C++ Libraries: Ticket #11556: hypergeometric constructor's n & r are not consistent with online description! https://svn.boost.org/trac10/ticket/11556 <p> Hi, at the following URL it reads: </p> <p> r: number of defective items n: size of sample </p> <p> <a href="http://www.boost.org/doc/libs/1_52_0/libs/math/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/hypergeometric_dist.html">http://www.boost.org/doc/libs/1_52_0/libs/math/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/hypergeometric_dist.html</a> </p> <p> However looking into the constructor of hypergeometric distribution reveals the contrary: </p> <p> r: sample size n: number of defective items </p> <pre class="wiki"> class hypergeometric_distribution { public: typedef RealType value_type; typedef Policy policy_type; hypergeometric_distribution(unsigned r, unsigned n, unsigned N) // Constructor. : m_n(n), m_N(N), m_r(r) { static const char* function = "boost::math::hypergeometric_distribution&lt;%1%&gt;::hypergeometric_distribution"; RealType ret; check_params(function, &amp;ret); } // Accessor functions. unsigned total()const { return m_N; } unsigned defective()const { return m_n; } unsigned sample_count()const { return m_r; } bool check_params(const char* function, RealType* result)const { if(m_r &gt; m_N) { *result = boost::math::policies::raise_domain_error&lt;RealType&gt;( function, "Parameter r out of range: must be &lt;= N but got %1%", static_cast&lt;RealType&gt;(m_r), Policy()); return false; } if(m_n &gt; m_N) { *result = boost::math::policies::raise_domain_error&lt;RealType&gt;( function, "Parameter n out of range: must be &lt;= N but got %1%", static_cast&lt;RealType&gt;(m_n), Policy()); return false; } return true; } bool check_x(unsigned x, const char* function, RealType* result)const { if(x &lt; static_cast&lt;unsigned&gt;((std::max)(0, (int)(m_n + m_r) - (int)(m_N)))) { *result = boost::math::policies::raise_domain_error&lt;RealType&gt;( function, "Random variable out of range: must be &gt; 0 and &gt; m + r - N but got %1%", static_cast&lt;RealType&gt;(x), Policy()); return false; } if(x &gt; (std::min)(m_r, m_n)) { *result = boost::math::policies::raise_domain_error&lt;RealType&gt;( function, "Random variable out of range: must be less than both n and r but got %1%", static_cast&lt;RealType&gt;(x), Policy()); return false; } return true; } private: // Data members: unsigned m_n; // number of "defective" items unsigned m_N; // number of "total" items unsigned m_r; // number of items picked }; // class hypergeometric_distribution </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11556 Trac 1.4.3 anonymous Wed, 19 Aug 2015 12:43:55 GMT summary changed https://svn.boost.org/trac10/ticket/11556#comment:1 https://svn.boost.org/trac10/ticket/11556#comment:1 <ul> <li><strong>summary</strong> <span class="trac-field-old">hypergeometric constructor's n &amp; r are consistent with online description!</span> → <span class="trac-field-new">hypergeometric constructor's n &amp; r are not consistent with online description!</span> </li> </ul> Ticket John Maddock Thu, 20 Aug 2015 08:10:20 GMT owner, component changed https://svn.boost.org/trac10/ticket/11556#comment:2 https://svn.boost.org/trac10/ticket/11556#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Matias Capeletto</span> to <span class="trac-author">John Maddock</span> </li> <li><strong>component</strong> <span class="trac-field-old">Documentation</span> → <span class="trac-field-new">math</span> </li> </ul> <p> Ooops! </p> <p> Will investigate, thanks for reporting that! </p> Ticket John Maddock Thu, 03 Sep 2015 17:48:54 GMT <link>https://svn.boost.org/trac10/ticket/11556#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11556#comment:3</guid> <description> <p> The documentation is correct, the comments in code are wrong, as are the member function getters defective() and sample_count(). If you follow the docs and ignore the code, then everything will work as documented. Will fix the other issues shortly. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Thu, 03 Sep 2015 18:24:03 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/11556#comment:4 https://svn.boost.org/trac10/ticket/11556#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> </ul> <p> Fixed in <a class="ext-link" href="https://github.com/boostorg/math/commit/9d3d2e96a0c39c6dc072832ab2e0e29e23682f24"><span class="icon">​</span>https://github.com/boostorg/math/commit/9d3d2e96a0c39c6dc072832ab2e0e29e23682f24</a> </p> Ticket