0

I am doing a lot of Metropolis-Hastings Markov chain Monte Carlo (MCMC). Most codes I have in use, use Mersenne Twister (MT) as pseudo random number generator (PRNG).

However, I recently read, that MT is outdated and probably shouldn't be used anymore as it fails some tests and is relatively slow. So I am willing to switch.

Numpy now defaults to PCG (https://www.pcg-random.org/), which claims to be good. Other sites are rather critical. E.g. http://pcg.di.unimi.it/pcg.php. It seems everyone praises its own work.

There is some good information already here: Pseudo-random number generator But many answers are already a bit dated and I want to formulate my question a bit more specific.

As I said: the main use case is Metropolis-Hastings MCMC. Therefore, I need:

  • uniformly distributed numbers in half-open and open intervals
  • around 2^50 samples, apparently per rule of thumb the PRNG should have a period of at least 2^128
  • sufficient quality of random numbers (whatever this might mean)
  • a reasonable fast PRNG (for a fixed runtime faster code means more accuracy for MCMC)

I do not need

  • cryptographically security

As I am by no means an expert, of course usability counts also. So I would welcome an available C++ implementation (this seems to be standard), which is sufficiently easy to use for the novice.

DerWeh
  • 1,721
  • 1
  • 15
  • 26
  • 1
    I maintain a list with suggested PRNGs. https://github.com/peteroupc/peteroupc.github.io/blob/master/hqprng.md . However, your question is not really a good fit for this site, since it's opinion-based and seeks recommendations for software. – Peter O. Oct 01 '20 at 21:45
  • 1
    Do you need jump ahead, advance, and similar features? – Severin Pappadeux Oct 02 '20 at 02:18
  • Opinions will differ as Peter O. said. I would suggest trying a few candidates to see which one works best for your use case. From among the generators offered by numpy, Philox is known to me as being a generator of high quality, typically better speed than Mersenne Twister, and with excellent skip (jump ahead) performance (as it is counter based). – njuffa Oct 02 '20 at 04:45
  • @SeverinPappadeux currently I don't need these features. Of course something future proof is never a bad idea. – DerWeh Oct 02 '20 at 06:41
  • I wasn't aware that this is such an opinionated issue. I expected that there is a sound choice. Sorry if this is the wrong place to ask. Trying something and see what's work is not really feasible. Checking if it works is a highly non-trivial task, which I am not capable of doing. – DerWeh Oct 02 '20 at 06:45
  • @DerWeh There are *many* sound choices, for some definition of sound; not every use case requires every feature equally. I have observed not just internet discussions on the merits of particular PRNGs over the decades, but *heated* discussions. Personally, I have stuck to the late professor George Marsaglia's KISS and KISS64 generators for decades (20 and 10 years respectively) for use cases requiring up to 2**48 random integers, and have yet to notice any practical issues. I don't need skipping, which is expensive to do with composite PRNGs like KISS{64}. – njuffa Oct 02 '20 at 07:40
  • @DerWhen I'm afraid at this point in time you just have to pick one. It may be that none of the various shortcomings that have been discovered in all of them are relevant to your application. PRNGs for statistical applications are designed with speed first and quality second. – President James K. Polk Oct 02 '20 at 17:17

0 Answers0