C# Mersenne Twister random integer generator implementation (SFMT) monte carlo simulation

后端 未结 5 1576
梦毁少年i
梦毁少年i 2021-02-01 10:37

So far I\'ve been using the C# Mersenne Twister found here to generate random numbers:

http://www.centerspace.net/resources.php

I just discovered SFMT

5条回答
  •  无人及你
    2021-02-01 11:13

    I don't really see your problem with speed here. On my machine (Core 2 Duo T7200 @ 2 GHz) generating a random integer with MT19937 or MT19937-64 takes around 20 ns (on average, when drawing 50000 numbers). So that'd be around 4,32 × 1012 (so around 4 trillion numbers) a day. And that's for one core. With Java. So I think you can expect the performance to be more than adequate for your needs.

    To actually answer your question: I don't know of a C# implementation of SFMT, but conversion of the C code to C# should be fairly straightforward. However, you're not gaining much, as SFMT is optimized for SIMD and C# currently doesn't support this directly.

提交回复
热议问题