The method that I am considering is from: http://ift.tt/2a83FKw
#include <random>
std::random_device rd; // only used once to initialise (seed) engine
std::mt19937 rng(rd()); // random-number engine used (Mersenne-Twister in this case)
std::uniform_int_distribution<int> uni(min,max); // guaranteed unbiased
auto random_integer = uni(rng);
I'm also willing to use the rand()
approach with srand(time(NULL))
.
My question: how expensive are these approaches? Is one much faster than the other?
Aucun commentaire:
Enregistrer un commentaire