samedi 23 mai 2020

Python multithreaded random generation

I am trying to implement in my simulation this code:

https://numpy.org/doc/stable/reference/random/multithreading.html

but I can't work it out.

If I follow the example in the link, I get

mrng = MultithreadedRNG(10000000, seed=0)
mrng.fill()
print(mrng.values[-1])
> 0.0

and all the other values are 0 too.

If I give a smaller input number, as 40, I get

mrng = MultithreadedRNG(40)
mrng.fill()
print(mrng.values[-1])
> array([1.08305179e-311, 1.08304781e-311, 1.36362118e-321,             nan,
       6.95195359e-310, ...., 7.27916164e-095, 3.81693953e+180])

What am I doing wrong? I just would like to implement this multiprocessing code to a random bits (0 / 1) generator.




Aucun commentaire:

Enregistrer un commentaire