0
我需要創建一個數字發生器,繪製具有帕累託分佈的數字在特定的時間間隔。我正在使用C++。繪圖編號與帕雷託分佈
我不能使用C++ 11的<random>
庫,所以我試圖通過使用boost庫來解決我的問題,在那裏我找到了類pareto_distribution。
還有關於這個話題的另一個問題,但他們提出的解決方案並不適合我。
任何人都可以幫助我嗎?
在此先感謝。
我需要創建一個數字發生器,繪製具有帕累託分佈的數字在特定的時間間隔。我正在使用C++。繪圖編號與帕雷託分佈
我不能使用C++ 11的<random>
庫,所以我試圖通過使用boost庫來解決我的問題,在那裏我找到了類pareto_distribution。
還有關於這個話題的另一個問題,但他們提出的解決方案並不適合我。
任何人都可以幫助我嗎?
在此先感謝。
這是我寫的劇本:
#include <iostream>
#include <boost/random/uniform_real_distribution.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/variate_generator.hpp>
#include <boost/math/distributions/pareto.hpp>
#include <time.h>
using namespace std;
int main()
{
boost::mt19937 *rg = new boost::mt19937();
rg->seed(time(NULL));
boost::math::pareto_distribution<> dist;
boost::random::uniform_real_distribution<> uniformReal(1.0,10.0);
boost::variate_generator<boost::mt19937&,boost::random::uniform_real_distribution<> > generator(rg, dist);
double cdfComplement;
cdfComplement = boost::math::complement::cdf(boost::math::complement(dist,generator()));
cout << " cdfComplement: " << cdfComplement << endl;
return 0;
}
它給了我一個錯誤在這一行:boost :: variate_generator
向我們展示你做了什麼 –
「但他們提出的解決方案並沒有爲我工作。」 - 你甚至沒有鏈接到它。所以沒有人應該浪費時間給你答案,因爲神祕的原因,這很可能「不適合你」。 – sehe
對不起,你是對的。這是我發現的上一個問題的鏈接:http://stackoverflow.com/questions/29155783/randomly-generated-numbers-from-boost-pareto-distribution?rq=1。我還附上了我根據該解決方案編寫的腳本以及錯誤。感謝您的建議 –