Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best pseudo-random number generator as of today? [closed]

Tags:

By best I mean the one that:

  • passes all statistical tests
  • behaves well even at very high dimensions
  • has an extremely large period

I can think of Mersenne Twister, but which variant is the best? Is there any better PRNG?

like image 402
Nishanth Avatar asked Jan 18 '11 05:01

Nishanth


People also ask

What is the best pseudo-random number generator?

If you look for an algorithm, that passes all statistical tests, but is still fast you could try the Xorshift-Algorithm. Compared with the random library in Java it is about 30% faster and provides better results. Its Period is not as long as the Mersenne Twister's but its still decent.

Do pseudorandom generators exist?

The pseudorandom generators used in cryptography and universal algorithmic derandomization have not been proven to exist, although their existence is widely believed. Proofs for their existence would imply proofs of lower bounds on the circuit complexity of certain explicit functions.

Can pseudo-random numbers be predicted?

The outcome of the research confirms the possibility that machine learning algorithms can be trained to predict certain PRNGs. Even when trained with a small amount of data, there is evidence that machine learning algorithms can be used to predict the values created by pseudorandom number generators.


1 Answers

Just a quick update, as the answers show their age: Today the Mersenne Twister is not really considered state of the art anymore (somewhat bloated, predictable given just 624 values, slow to seed, bad seeding possible, ...).

Normal PRNG

For normal applications, where good statistical properties and speed are important, consider

  • O'Neill's PCG family,
  • Vigna's xoroshiro family, say xoroshiro128+ (not a Japanese name btw, but "X-or, rotate, shift, rotate"), and
  • D. E. Shaw's Random123 suite (which includes Philox and the nicely named ARS, a simplification of encrypting an infinite sequence of zeros with AES-CTR), though I'm not sure how much the Random123 PRNG have been scrutinised.

Cryptographically secure PRNG (CSPRNG)

For cryptographic applications, where non-predictability is important, consider a cryptographically secure PRNG, such as

  • Bernstein's ChaCha20, RFC 7539. Alternatives would be
  • Wu's HC-256,
  • Jenkins's ISAAC64.

Note: In a previous version I stated that the Random123 algorithms are cryptographically secure, but they're not.

PRNG Testing

Similarly, for statistical tests of PRNG, nowadays the state of the art is probably

  • L'Ecuyer's TestU01 (with SmallCrush, Crush, BigCrush),
  • Doty-Humphrey's pracrand with its PractRand suite,

while these are historically important, but outdated:

  • Marsaglia's DieHard, DieHarder,
  • NIST 800-22 A.
like image 173
Fab Avatar answered Sep 28 '22 05:09

Fab