https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83237
Bug ID: 83237
Summary: Values returned by std::poisson_distribution are not
distributed correctly
Product: gcc
Version: 7.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: christoph at kohlio dot de
Target Milestone: ---
Values returned by std::poisson_distribution are not distributed according to a
Poisson distribution with the given mean. Apparently there is a problem
generating variates around the mean value.
Example code which generates 1E8 variates:
#include <array>
#include <cmath>
#include <iostream>
#include <random>
int main() {
// The problem turned out to be independent on the engine
std::mt19937_64 engine;
// Set fixed seed for easy reproducibility
// The problem turned out to be independent on seed
engine.seed(1);
std::poisson_distribution<int> distribution(157.17);
for (int i = 0; i < 1E8; i++) {
const int number = distribution(engine);
std::cout << number << std::endl;
}
}
There is a strong deviation from the expected statistics in bin 158, as shown
in the following SO question:
https://stackoverflow.com/questions/47586495/bug-in-the-c-standard-library-in-stdpoisson-distribution/47587735#47587735