【发布时间】:2010-11-10 05:57:46
【问题描述】:
我正在尝试使用 C++ STD TechnicalReport1 扩展来生成服从正态分布的数字,但是这段代码(改编自 this article):
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;
}
只打印 1 条“正在生成...”日志消息,然后 永远不会退出 for 循环!如果我使用我注释掉的发行版,它会终止,所以我想知道我做错了什么。有什么想法吗?
非常感谢!
【问题讨论】:
标签: c++ tr1 normal-distribution