I need to generate random numbers representing user activities using chi square distribution in (boost) tr1 c++. Any example or help on how would I start?
I tried the following code:
int main (){
std::tr1::mt19937 eng; // a core engine class
//mt19937 is a very fast random number generator algorithm
eng.seed(time(0)); //each engine has a seed method
//file to store seed
std::tr1::chi_squared_distribution<double> chdist(5.0);
cout<<endl<<"CHIDIST"<<endl<<"================"<<endl;
for (int i = 0; i<50; ++i)
{
Act.push_back(chdist(eng)*0.1);
int rounded = ((int)(chdist(eng) * 100 + .5) / 100.0);
Act.push_back(rounded*0.1); cout<<Act[i]<< endl;
}
return 0;
}