Using same random number generator across multiple functions
问题 I am given to believe that random number generators (RNGs) should only be seeded once to ensure that the distribution of results is as intended. I am writing a Monte Carlo simulation in C++ which consists of a main function ("A") calling another function ("B") several times, where a large quantity of random numbers is generated in B. Currently, I am doing the following in B: void B(){ std::array<int, std::mt19937::state_size> seed_data; std::random_device r; std::generate(seed_data.begin(),