I am trying to generate uniformly distributed random numbers with the mt19937 engine and std::random_device as the seed source. If I get lucky I get a couple hundred thousands unique number out of the 4 billion possible values. I was wondering if it could get any better than this.
I attempted to increase the entropy using high resolution timer and the random device using seed_seq (https://stackoverflow.com/a/34493057/5852409) also tried initializing all the 624 states of the mt19937 (https://codereview.stackexchange.com/a/109266). However, did not see any improvement.
#include <random>
#include <iostream>
#include <set>
void main()
{
std::random_device rd;
std::mt19937 engn(rd());
std::uniform_int_distribution<unsigned int> unidist(0, 0xFFFFFFFF - 1);
std::set<unsigned int> s;
auto itr = s.insert(unidist(engn));
int k = 0;
while (itr.second)
{
itr = s.insert(unidist(engn));
k++;
}
std::cout << k << '\n';
}