I'm developing a program for Monte Carlo integration and using std::mt19937 as the generator.
Sorry I cannot paste my code here, but it's something like:
long long result = 0;
std::mt19937 rng(std::random_device()());
while (/*continue*/) {
result += f(rng()); // do some calculation
// for (int i = 0; i < 30; i++) rng(); // unused generations
}
// some other calculations
With a fixed number of samples, the Monte Carlo estimation seems to be more accurate if I uncomment the "unused generations" line. Further, if I increase the number of unused generations (say 30 -> 50), error seems to get even lower.
The unused generations indeed change the internal state of generator, but is it possible to yield better distribution by doing this?
Changing the seed didn't change this phenomenon.
(I know my question is somehow vague) I'm wondering if anyone has similar experience.
Anything could be helpful. Thank you in advance!
Aucun commentaire:
Enregistrer un commentaire