Código
#include <iostream> #include <random> #include <cstdlib> #include <ctime> int main(int argc, char **argv) { std::mt19937 rng; std::srand(time(NULL)); uint32_t seed = std::rand(); rng.seed(seed); uint32_t stats[10] = {0}, current; std::cout << "*** Random number generation test ***" << std::endl; std::uniform_int_distribution<uint32_t> uint_dist(0, 10); for(size_t i=0; i<56000u; i++) { current = uint_dist(rng); stats[current-1]++; std::cout << current << ' ' << std::endl; } std::cout << "*** Number of times for each number ***" << std::endl; size_t i=1; for(auto x : stats) { std::cout << "$ " << i++ << '\t' << x << std::endl; } std::cout << "*** End of the test ***" << std::endl; return 0; }
Los resultados son bastante uniformes