[R-pkg-devel] Change in normal random numbers between R 3.5.3 and R 3.6.0
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Thu May 9 16:19:26 CEST 2019
On 09/05/2019 9:15 a.m., Ulrike Grömping wrote:
> Dear R package authors,
>
> I am currently struggling with differences in test results between R
> versions 3.5.3 and 3.6.0: There are expected ones (from the new behavior
> of sample(), which can be switched off by
> RNGkind(sample.kind="Rounding")) and unexpected ones: The normal random
> numbers from a call "y <- rnorm(36)" have changed between R versions, in
> spite of working with a seed. Consequently, most other outcomes change
> as well, as they depend on those random numbers.
>
> Does anyone have an idea what this behavior results from ? You see
> samples below (ignore the first columns, these can be made alike by
> changing sample.kind; but the normal random numbers in the last column
> were the bottom ones before version 3.6.0 and are the top ones afterwards.
>
>>
>> < 1 200 10 -25 -2.07823754
>> < 2 150 30 25 0.48522682
>> < 3 200 20 -25 0.69676878
>>
>> ...
>>
>>> 1 250 10 -15 -0.820426525
>>> 2 200 10 -25 -1.238082813
>>> 3 100 10 15 -1.199567511
> ...
>
> Can anyone explain, why this is the case, or how I could possibly
> circumvent it (for some noLD checks)?
>
I am not seeing a difference in rnorm(), but I would expect to see one
if the new sample() code was used, as it can make a different number of
calls to the underlying RNG.
That is: I'd expect this code to give identical results in both
versions, whether I used val <- 10 or any other value:
val <- 10
set.seed(val)
rnorm(36)
This code does not give identical results, because the calls to sample()
will result in different changes to the seed:
val <- 10
set.seed(val)
discard <- sample(1000, 100)
rnorm(36)
Duncan Murdoch
More information about the R-package-devel
mailing list