简体   繁体   English

numpy.random和蒙特卡洛

[英]numpy.random and Monte Carlo

I wrote a Monte Carlo (MC) code in Python with a Fortran extension (compiled with f2py). 我用Python编写了带有Fortran扩展名的Monte Carlo(MC)代码(与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. 由于它是随机积分,因此该算法在很大程度上依赖于随机数,即对于典型的运行,我使用~ 10^8 - 10^9随机数。 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? 我的问题是:numpy使用的Mersenne-Twister是否足够?还是有(应该)使用更好的随机数生成器? (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. 我要做的是用其他方式替换numpy随机数,当然,已经有其他模块提供了不同的算法。 If your simulation results are not affected by the choice of random number generator, it is already a good sign. 如果您的模拟结果不受随机数生成器选择的影响,那么这已经是一个好兆头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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