Hi.
This patch intends to fix Bug 83237 - Values returned by
std::poisson_distribution are not distributed correctly.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83237for issue
description and tests.
* include/bits/random.tcc (poisson_distribution<_IntType>::operator()):
Value of the comparison function shall be set to 1/78 for __x = 1
diff --git a/random.tcc b/random.tcc
index 95bcf0a..f36587e 100644
--- a/random.tcc
+++ b/random.tcc
@@ -1301,6 +1301,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const double __c2 = __param._M_c2b + __c1;
const double __c3 = __c2 + 1;
const double __c4 = __c3 + 1;
+ // 1 / 78
+ const double __178 = 0.0128205128205128205128205128205128L;
// e^(1 / 78)
const double __e178 = 1.0129030479320018583185514777512983L;
const double __c5 = __c4 + __e178;
@@ -1340,7 +1342,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
else if (__u <= __c4)
__x = 0;
else if (__u <= __c5)
+ {
__x = 1;
+ __w = __178;
+ }
else
{
const double __v = -std::log(1.0 - __aurng());