Strange use of random values in regression test ...
The test_main() of libs/utility/operators_test.cpp loops 1000 times, running a variety of tests on random values. However, since the randomizer (boost::minstd_rand) is instantiated inside the loop, it appears that the randomizer is re-seeded for each loop, meaning it runs the test 1000x with the exact same values each time. I’m not 100% familiar with the boost random value generators, am I missing something? Or should the boost::minstd_rand be instantiated outside the loop? I’m happy to add this as a boost bug if my understanding is correct … Thanks, Chris
On 21 Apr 2014, at 18:55, Chris Cooper
The test_main() of libs/utility/operators_test.cpp loops 1000 times, running a variety of tests on random values. However, since the randomizer (boost::minstd_rand) is instantiated inside the loop, it appears that the randomizer is re-seeded for each loop, meaning it runs the test 1000x with the exact same values each time.
I’m not 100% familiar with the boost random value generators, am I missing something? Or should the boost::minstd_rand be instantiated outside the loop?
I’m happy to add this as a boost bug if my understanding is correct …
Thanks, Chris
Yes you need to put it outside the loop. When the random object is created it’s set to the same default seed.
participants (2)
-
Chris Cooper
-
Thijs van den Berg