我一直在玩Boost.Random一天,而boost::uniform_int_distribution<>
效果很好,我遇到了問題boost::exponential_distribution<>
。如何使boost :: exponential_distribution工作?
一個簡單的程序是勝過千言萬語:
#include <iostream>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/exponential_distribution.hpp>
int main() {
boost::mt19937 gen;
boost::exponential_distribution<> dis;
std::cout << dis(gen) << "\n";
return 0;
}
編譯鏗鏘3.0,使用Boost 1.39.1(不,我不能升級加速)。
輸出總是相同的:nan
。
我找不到任何報告的問題,所以我想這是我沒有正確使用庫...任何線索將不勝感激。
該代碼給了我最新的boost(1.48)與gcc 1.68591'(抱歉,不能幫助其他任何事情)。 – 2012-01-30 09:01:41
@Jesse:感謝您的測試:) – 2012-01-30 09:16:09