我想我从C++标准库遇到了std :: poisson_distribution的错误行为.
以下C++代码(文件poisson_test.cc)用于生成泊松分布数:
#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;
}
}
Run Code Online (Sandbox Code Playgroud)
我按如下方式编译此代码:
clang++ -o poisson_test -std=c++11 poisson_test.cc …Run Code Online (Sandbox Code Playgroud)