I am trying to reproduce the C++ code into Python 3.6, but the sequence of pseudo random numbers is different in each implementation. The seed are the same on both implementation and as far as I know, both use Mersenne Twister algorithm.
What am I doing wrong?
C++:
#include <random>
#include <iostream>
int main(int argc, char* argv[])
{
std::mt19937 gen(2);
std::uniform_int_distribution<> dis(0, 61);
for (int n=0; n<10; ++n)
std::cout << dis(gen) << ' ';
return 0;
}
Python 3.6:
import numpy as np
rng = np.random.RandomState(2)
for i in range(10):
print(str(rng.randint(0, 62)))
Note: randint
has an exclusive upper bound. That is why I use 61 on C++ code, but 62 on Python code.
Aucun commentaire:
Enregistrer un commentaire