[R] How to construct a valid seed for l'Ecuyer's method with given .Random.seed?
Marius Hofert
marius.hofert at math.ethz.ch
Wed Jan 23 23:24:11 CET 2013
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 you
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:
RNGkind()
set.seed(1)
.Random.seed[-1]
RNGkind("L'Ecuyer-CMRG")
.Random.seed[-1] # => unsigned
seed <- .Random.seed[-1] + 2^32 # => shifting
require(rlecuyer)
.lec.SetPackageSeed(seed)
... but it fails with
,----
| Error in .lec.SetPackageSeed(seed) : Seed[1] >= 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 length
checks) in R, maybe in .lec.CheckSeed(). That would rule out further problems
and strange error messages from C, which are harder to debug.
What are the precise conditions for the seed in 'rlecuyer'? Judging from the
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.
Cheers,
Marius
Hana Sevcikova <hanas at uw.edu> writes:
> Marius,
>
> I looked it up in the original L'Ecuyer's paper: The seed must be larger than
> 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 not
> familiar with it), but they seem to relax that restriction.
>
> Hana
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130123/c79c5366/attachment.bin>
More information about the R-help
mailing list