[R] How to construct a valid seed for l'Ecuyer's method withgiven .Random.seed?
djnordlund at frontier.com
Thu Jan 24 00:49:24 CET 2013
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of Marius Hofert
> Sent: Wednesday, January 23, 2013 2:24 PM
> To: Hana Sevcikova
> Cc: R-help
> Subject: Re: [R] How to construct a valid seed for l'Ecuyer's method
> withgiven .Random.seed?
> Dear Hana,
> Thanks for helping.
> I am still wondering, why m1 (which should be 2^32-209 [see line 34 in
> ./src/RngStream.c]) is -767742437 in my case and why the minimal example
> gave was working for you but isn't for me.
> Apart from that, ?.Random.seed -> "L'Ecuyer-CMRG" says:
> | The 6 elements of the seed are internally regarded as 32-bit
> | unsigned integers. Neither the first three nor the last
> | three should be all zero, and they are limited to less than
> | ‘4294967087’ and ‘4294944443’ respectively.
> => .Random.seed provides a *signed* integer. I tried to convert it to an
> unsigned integer:
> .Random.seed[-1] # => unsigned
> seed <- .Random.seed[-1] + 2^32 # => shifting
> ... but it fails with
> | Error in .lec.SetPackageSeed(seed) : Seed >= 14, Seed is not set.
> => so there seem to be the requirement that the second element of the seed
> is <
> 14 (???).
> I might have done the conversion to a signed integer incorrectly, though.
> It would be great if the seed was checked *precisely* (not just basic
> checks) in R, maybe in .lec.CheckSeed(). That would rule out further
> and strange error messages from C, which are harder to debug.
> What are the precise conditions for the seed in 'rlecuyer'? Judging from
> above error, the second element must be < 14. But, additionally,... ?
> I hope there is a solution to the problem of "how to convert .Random.seed
> to get
> a valid seed for 'rlecuyer'"... we need that in a package.
> Hana Sevcikova <hanas at uw.edu> writes:
> > Marius,
> > I looked it up in the original L'Ecuyer's paper: The seed must be larger
> > 0. Thus, the function defines the seed variable as unsigned long
> integer. You're
> > passing a negative number, so I think there is some overflow going on.
> > The internal L'Ecuyer RNG is a modification of the original one (and I'm
> > familiar with it), but they seem to relax that restriction.
> > Hana
I apologize if this message is posted twice. I am having email problems.
I think the confusion about negative numbers is that R represents the seed values as signed integers, but the underlying C code interprets those values as unsigned integers. At least that is how I read the documentation on .Random.seed
Hope this is helpful,
Bothell, WA USA
More information about the R-help