lundi 17 décembre 2018

C++ pseudo random number generation platform dependency

Is there anything in the code below that is platform or compiler dependent? It gives different values when compiled with g++ in cygwin than it does when compiled with VC++. I would like to remove any such dependencies if possible.

minstd_rand0 engine;
engine.seed(3113722101);
uniform_int_distribution<int> day_dist(1, 365);
uniform_real_distribution<double> quant_dist(0.0, 1.0);
ofstream fout(argv[1]);
for (int i = 0; i < years; ++i) {
    fout << (i + 1) << "\t";
    fout << day_dist(engine) << "\t";
    fout << quant_dist(engine) << "\t";
    fout << quant_dist(engine) << "\t";
    fout << quant_dist(engine) << "\n";
}
fout.close();




Aucun commentaire:

Enregistrer un commentaire