lundi 6 avril 2015

Generate identical random numbers in R and Julia

I'd like to generate identical random numbers in R and Julia. Both languages appear to use the Mersenne-Twister library by default, however in Julia:



srand(3)
rand()


Produces 0.975, while in R:



set.seed(3)
runif(1)


produces 0.168.


Any ideas?


Related SO questions here and here.


My use case for those who are interested: Testing new Julia code that requires random number generation (e.g. statistical bootstrapping) by comparing output to that from equivalent libraries in R.





Aucun commentaire:

Enregistrer un commentaire