简体   繁体   中英

numpy.random and Monte Carlo

I wrote a Monte Carlo (MC) code in Python with a Fortran extension (compiled with f2py). As it is a stochastic integration, the algorithm relies heavily on random numbers, namely I use ~ 10^8 - 10^9 random numbers for a typical run. So far, I didn't really mind the 'quality' of the random numbers - this is, however, something that I want to check out.

My question is: does the Mersenne-Twister used by numpy suffice or are there better random number generators out there that one should (could) use? (better in the sense of runtime as well as quality of the generated sequence)

Any suggestions/experiences are most definitely welcome, thanks!

I do not think anyone can tell you if this algorithm suffices without knowing how the random numbers are being used.

What I would do is to replace the numpy random numbers by something else, certainly there are other modules already available that provide different algorithms. If your simulation results are not affected by the choice of random number generator, it is already a good sign.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM