4

I use pseudo random number generators (PRNG) to Monte Carlo simulate a queueing type of system. I use System.Random, because it is fast, but found out that it has some weird correlation between subsequent draws, which interferes with the results (it is not random enough).

Now I am using Mersenne Twister (http://takel.jp/mt/MersenneTwister.cs), which (up until now) has proven to be random enough for my purposes. It is 50% slower, but that is a price I am willing to pay to get reliable results.

What PRNG for .net is most suitable for Monte Carlo simulation? I am looking for a reliable PRNG that is not too slow.

willem
  • 2,617
  • 5
  • 26
  • 38
  • Try *quasirandom* numbers (e.g., low-discrepancy sequences). https://en.wikipedia.org/wiki/Low-discrepancy_sequence –  Feb 24 '16 at 18:32

2 Answers2

4

The Mersenne Twister has been optimized for use with Monte Carlo simulations in a number of fields, so i would stick to that one.

If performance is an issue and going parralell is not an option i would go for an XORshift generator. A very good (fast) random number generator from Geroge Marsaglia.

Here's the paper:

That is probably your best bet if you need a good and fast PRNG for some monte carlo or other statistical simulations, not for cryptography though.

At this SO post you can find a very simple port in JAVA, but should be not that hard to rewrite or find a C# implementation on the net.

Community
  • 1
  • 1
Frank
  • 16,476
  • 7
  • 38
  • 51
0

you can also use SIMD-oriented Fast Mersenne Twister (SFMT), which is very fast, it uses SIMD instruction to generate random number in parallel. it can be found in Home Page of Makoto Matsumoto:

http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html

mehrdad
  • 161
  • 2
  • 11