Opened 7 years ago
Closed 7 years ago
#11556 closed Bugs (fixed)
hypergeometric constructor's n & r are not consistent with online description!
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | Boost 1.60.0 | Component: | math |
Version: | Boost 1.59.0 | Severity: | Problem |
Keywords: | hypergeometric constructor n r | Cc: | mor.chalabi@… |
Description
Hi, at the following URL it reads:
r: number of defective items n: size of sample
However looking into the constructor of hypergeometric distribution reveals the contrary:
r: sample size n: number of defective items
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<%1%>::hypergeometric_distribution"; RealType ret; check_params(function, &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 > m_N) { *result = boost::math::policies::raise_domain_error<RealType>( function, "Parameter r out of range: must be <= N but got %1%", static_cast<RealType>(m_r), Policy()); return false; } if(m_n > m_N) { *result = boost::math::policies::raise_domain_error<RealType>( function, "Parameter n out of range: must be <= N but got %1%", static_cast<RealType>(m_n), Policy()); return false; } return true; } bool check_x(unsigned x, const char* function, RealType* result)const { if(x < static_cast<unsigned>((std::max)(0, (int)(m_n + m_r) - (int)(m_N)))) { *result = boost::math::policies::raise_domain_error<RealType>( function, "Random variable out of range: must be > 0 and > m + r - N but got %1%", static_cast<RealType>(x), Policy()); return false; } if(x > (std::min)(m_r, m_n)) { *result = boost::math::policies::raise_domain_error<RealType>( function, "Random variable out of range: must be less than both n and r but got %1%", static_cast<RealType>(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
Change History (4)
comment:1 by , 7 years ago
Summary: | hypergeometric constructor's n & r are consistent with online description! → hypergeometric constructor's n & r are not consistent with online description! |
---|
comment:2 by , 7 years ago
Component: | Documentation → math |
---|---|
Owner: | changed from | to
comment:3 by , 7 years ago
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.
comment:4 by , 7 years ago
Milestone: | To Be Determined → Boost 1.60.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Ooops!
Will investigate, thanks for reporting that!