简体   繁体   English

SFMT与Mersenne Twister和Ran2的比较

[英]Comparing SFMT with Mersenne Twister and Ran2

I am trying to optimise a C-based code used for bioinformatic purposes. 我正在尝试优化用于生物信息学目的的基于C的代码。 It uses Monte Carlo iterations for major part of the calculations. 它使用蒙特卡洛迭代进行计算的主要部分。 It earlier used ran2() for generating random numbers, which was making it super slow. 之前它使用ran2()生成随机数,这使它变得非常慢。 After thorough research, I found that mersenne twister, and sfmt are more efficient random number generators. 经过深入研究,我发现mersenne twister和sfmt是更有效的随机数生成器。 However, I tried using them in my code, and they seem to be making not much of a difference in the speed. 但是,我尝试在代码中使用它们,它们的速度似乎并没有太大差异。 Given the fact that the program uses generator 10+ times for each iteration, I am not able to figure out why changing the generator is making no difference to the speed. 鉴于该程序每次迭代都会使用生成器10次以上,因此我无法弄清楚为什么更改生成器对速度没有影响。

Could anyone tell me where am I possibly going wrong? 谁能告诉我我可能在哪里出问题?

Choosing a random number generator is always a balance between quality (of the numbers they generate) and speed. 选择随机数生成器始终是质量(生成的数字)和速度之间的平衡。 Linear congruential generators are typically the fastest, but they are not suitable for any serious Monte Carlo work. 线性同余生成器通常是最快的,但是它们适合任何严肃的蒙特卡洛工作。

From experience I'd say that mersenne twister is just fine --- it's not superslow and you don't have to worry about the quality. 根据经验,我会说mersenne捻线器就很好---它并不慢,您不必担心质量。 As long as the bottleneck is in the generator, I'd say there's not much you can do on a single core. 只要瓶颈在生成器中,我想说在一个内核上您将无能为力。

This being said, here's a comparison of several generators: http://www.boost.org/doc/libs/1_48_0/doc/html/boost_random/performance.html 话虽如此,这里是几种生成器的比较: http : //www.boost.org/doc/libs/1_48_0/doc/html/boost_random/performance.html

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

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