Closed mb706 closed 1 month ago
The ran3()
function seems to be from Numerical Recipes in C, Chapter 7.1. Note that there, the initialization of mj
is
mj=labs(MSEED-labs(*idum));
which avoids negative values by using labs
.
Greetings,
Apologies for the lengthy delay. Thanks for your diligent sleuthing, I will be sure to incorporate this in the next update.
Jeff
The following causes the R session to freeze:
This finishes within a few seconds when using a smaller seed, but this particular seed causes the session to hang.
I believe what is happening is that the
ran3()
-code does not anticipate negative values here. Note that the C%
-operator returns negative values when its left-hand operand is negative. If the initial seed is large enough, theran3()
return values are no longer between 0 and 1 after a few invocations. The result is an essentially endless loop here.Not every large value leads to an R session freeze. I only stumbled upon this because my script runs many restarts with new (random) seeds every time.
The smallest seed that I could find that froze the session is
540714429
. If you want to "mine" for seeds that break the session, you can doOnce the output gets stuck at
Multistart n of 5 |
, the session is dead.