lundi 1 février 2016

Make PRNGs Agree Across Software

I am investigating whether it is possible to have two sets of software agree on a sequence of produced pseudo-random numbers.

Both R and Python's default random number generator is Mersenne-Twister. I set them to the same seed and try to sample from and also look at the "state" of the PRNG. Neither value agrees.

R (3.2.3, 64-bit):

set.seed(20160201)
.Random.seed
sample(c(1, 2, 3, 4, 5))

Python (3.5.1, 64-bit):

import random

random.seed(20160201)
random.getstate()
random.sample([1, 2, 3, 4, 5], 5)

I can think of several sources of the problem and I am as interested in understanding all the possible points of divergence as I am in actually finding a way to get them to agree.




Aucun commentaire:

Enregistrer un commentaire