Initializing all bits of internal state of a pseudo-random number generator
In the previous recipe, we have looked at the pseudo-random number library with its components and how it can be used to produce numbers in different statistical distributions. One important factor that was overlooked in that recipe is the proper initialization of the pseudo-random number generators. In this recipe, you will learn how to initialize a generator in order to produce the best sequence of pseudo-random numbers.
Getting ready
You should read the previous recipe, Generating pseudo-random numbers, to get an overview of what the pseudo-random number library offers.
How to do it...
To properly initialize a pseudo-random number generator to produce the best sequence of pseudo-random numbers, perform the following steps:
- Use an
std::random_device
to produce random numbers to be used as seeding values:
std::random_device rd;
- Generate random data for all internal bits of the engine:
std::array<int,...