相关疑难解决方法(0)

C++ TR1:如何使用normal_distribution?

我正在尝试使用C++ STD TechnicalReport1扩展来生成正常分布后的数字,但是这段代码(改编自本文):

mt19937 eng;
eng.seed(SEED);

normal_distribution<double> dist;
// XXX if I use the one below it exits the for loop
// uniform_int<int> dist(1, 52);

for (unsigned int i = 0; i < 1000; ++i) {
  cout << "Generating " << i << "-th value" << endl;
  cout << dist(eng) << endl;
}
Run Code Online (Sandbox Code Playgroud)

只打印1"Generating ..."日志消息,然后永远不会退出for循环!如果我使用我注释掉的发行版,它会终止,所以我想知道我做错了什么.任何的想法?

非常感谢!

c++ normal-distribution tr1

9
推荐指数
2
解决办法
9925
查看次数

标签 统计

c++ ×1

normal-distribution ×1

tr1 ×1