[R] .Random.seed for the Mersenne Twister
||gge@ @end|ng |rom @t@t|@t|k@tu-dortmund@de
Thu Jan 9 18:17:48 CET 2020
Exactly, from ?.Random.seed:
"In the underlying C, .Random.seed[-1] is unsigned; therefore in R
.Random.seed[-1] can be negative, due to the representation of an
unsigned integer by a signed integer. "
"It can be saved and restored, but should not be altered by the user. "
On 09.01.2020 16:40, Jeff Newmiller wrote:
> I am no expert on this specific algorithm, but there is no "32-bit unsigned integer" type in R. Presumably the interpretation of those negative numbers in the C code is as if they were unsigned while R presents them as if they were signed because it cannot do otherwise.
> AFAIK you need to use set.seed to configure .Random.seed, and you can retrieve and later restore the vectors created this way in the future. As I understand it there exist invalid vectors that cannot arbitrarily be used by this algorithm so generating them yourself is at the very least hard, and possibly could break in future versions of R.
> On January 9, 2020 1:18:01 AM PST, Luca Passalacqua via R-help <r-help using r-project.org> wrote:
>> Dear R users,
>> inspecting .Random.seed for the Mersenne Twister (MT) I find (many)
>> negative values for the
>> 624 values of the initial state of the generator.
>> It seems to me that this is a bug (an unsigned integer mapped to a
>> integer ?),
>> since, to my understanding, the R version of MT should be working with
>> 32-bits unsigned long.
>> Moreover, this prevents starting the generator by setting .Random.seed
>> user provided
>> Could someone please provide some insight to this issue ?
>> Many thanks,
>> Luca Passalacqua
>>> RNGkind('default')> RNGkind() "Mersenne-Twister" "Inversion"
>>> set.seed(1)> .Random.seed  403 624 -169270483
>> -442010614 -603558397 ...
More information about the R-help