jeudi 28 octobre 2021

In R, how can I get PRNG to give identical floating point numbers between platforms?

Running the following code in R 4.1.1 gives different results between platforms.

set.seed(1)
x <- rnorm(3)[3]
print(x, 22)

From Intel Windows:

#    1234567890123456 (digits)
# -0.83562861241004716

From M1 Mac:

#    1234567890123456 (digits)
# -0.8356286124100471557341

I know the size of difference is below .Machine$double.eps and the extra digits do not carry meaningful information.

I am not happy with the fact that extra digits exist. How can I ensure exactly consistent results? Is there an RNG library that achieves this?

round(x, 15) does not work:

print(round(x, 15), 22)
# -0.83562861241004704      (Intel Windows)
# -0.8356286124100470447118 (M1 Mac)



Aucun commentaire:

Enregistrer un commentaire