Skip to content
Prev 33632 / 63424 Next

user supplied random number generators

On Sun, 2009-08-16 at 21:24 +0200, Petr Savicky wrote:
I did figure out some of the lifetime issues; SPRNG does allocate memory
when you ask it for its state.  I also realized that for several reasons
it would not be appropriate to hand that buffer to R.

I've reworked the page extensively since it had the section you quote.
See particularly the "Getting and Setting Stream State" section near the
bottom.

I submitted patches to hook rsprng into R's standard machinery for
stream state (the user visible part of which is .Random.seed).  The
package developer has reservations about applying them.

As a practical matter, I shifted my package's C code to call back to R
to get random numbers.  If rsprng is loaded and activated, my code will
use it.  I also eliminated all attempts to set the seed in my code.  For
rsprng, in its current form, the R set.seed() function is a no-op and
you have to use an rsprng function to set the seed (generally when
activating the library).
That sounds interesting; thanks for pointing it out.
I think that one could write to .Random.seed directly to set a vector
for many of the generators.  ?.Random.seed does not recommend this and
notes various limits and hazards of this strategy.

Ross