I am iteratively generating random numbers via std::discrete_distribution
. Does the quality of random numbers degrade if after each iteration I reset the internal state of the distribution (which is equivalent to creating std::discrete_distribution
object inside the loop):
// inputs:
// int n_samples
// int n_energies
// double energies[n_energies]
std::mt19937_64 generator;
for (int i = 0; i < n_samples; ++i ) {
std::discrete_distribution<int> d(energies, energies + n_energies);
int index = d(generator);
// DO SMTH WITH INDEX
// energies array may change between iterations here.
}
The reason I am asking is that energies
may change between iterations (depending on the algorithm flow, which is not predictable).
In one border case, they change every iteration so above code is ok, since there is nothing I can do here.
In the other border case, they do not change between iterations at all. Which is equivalent to resetting internal state of std::discrete_distribution
while probabilities are the same.
In the latter case, is the quality of generated random numbers inferior to the quality when distribution state is not reset (i.e., std::discrete_distribution
object is created outside the loop)?
Aucun commentaire:
Enregistrer un commentaire