![]() |
|
good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^13: PDL and srand puzzle - MCE v1.892, v1.893 updatesby marioroy (Prior) |
on Jun 08, 2024 at 05:55 UTC ( [id://11159830]=note: print w/replies, xml ) | Need Help?? |
From etj: Could you take a look at the srand code and see if anything is obviously wrong? Also, are you able to see if the duplicates are in groups i.e. sequences? From Rob: We need to be looking at how those values were derived. I'm hoping for the PDL development team to chime in. The testing was out of curiosity. Running non-threads here, PDL generates approximately one billion unique. For threads (uncomment use threads at the top of the script), greater than 92% unique. Better than Math::Random::random_normal/random_uniform. Calling PDL::srandom has no effect for predictability, before spawning workers. I commented out the line in my last post. It requires calling CORE::srand instead. Care is needed whether to call a PDL function or class method.
I completed validation on the MCE side. Spawning child processes (non-threads), nearly one billion unique > 99.99995% for PDL->random, Math::Prime::Util::drand(), and Math::Random::MT::Auto::rand(). 80% ~ 82% unique for Math::Random::random_uniform() and Math::Random::random_normal(). Running threads, Math::Random::random_normal and random_uniform take beyond 2 minutes to output one billion lines and score less than 20% unique. The relevant code in MCE 1.891 can be found here lines 644-662 and here lines 2036-2071. MCE::Child and MCE::Hobo have similar code. See also, Random Numbers Overview by danaj. Update: It turns out that I can seed the generator inside threads for CORE, Math::Prime::Util, and Math::Random::MT::Auto and have predictable results, matching non-threads. I released MCE v1.892/v1.893, removing the check whether spinning threads. v1.893 preserves calling CORE::srand(N) for older Perl, non-threads.
In Section
Seekers of Perl Wisdom
|
|