Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [A5] Random numbers

This thread is locked; no one can reply to it. rss feed Print
 1   2 
[A5] Random numbers
Vanneto
Member #8,643
May 2007

Yes, sorry, PRNG.

In capitalist America bank robs you.

Audric
Member #907
January 2001

I propose the adoption of the term NPRNG (Non-Pseudo-Random Number Generator) to lift this old ambiguity. 8-)
Either it's pseudo-random, or it's non-pseudo random.

orz
Member #565
August 2000

I wrote a C++ RNG library available at
https://sourceforge.net/projects/pracrand/

The Mersenne Twister, mentioned in previous posts, generally produces decent quality output at decent speeds. There are plenty of RNGs that produce better output at better speeds with much smaller state sizes & initialization times though.

Generally my default RNG is Bob Jenkins small fast PRNG:
http://burtleburtle.net/bob/rand/smallprng.html

Arthur Kalliokoski
Second in Command
February 2005
avatar

Audric said:

I propose the adoption of the term NPRNG (Non-Pseudo-Random Number Generator) to lift this old ambiguity.

Do we have to drag this out again?

{"name":"random_number.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/3\/83ad4bb68067b16d8072f66715c945bb.png","w":400,"h":144,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/3\/83ad4bb68067b16d8072f66715c945bb"}random_number.png

They all watch too much MSNBC... they get ideas.

Goalie Ca
Member #2,579
July 2002
avatar

I've used the GNU random number generator ones in scientific papers. They are open source (+1 for reviewers) and they are generally fast and effective. They are written in C and easy to link with :)

http://www.gnu.org/software/gsl/manual/html_node/Random-number-generator-algorithms.html

-------------
Bah weep granah weep nini bong!

type568
Member #8,381
March 2007
avatar

Wow, now that's a rare case here on A.cc:

The derailment of the topic actually has given relevant suggestions to the OP. Although it looks like he saw what we're talking here about and quickly ran away to the SDL library forums..

Append:
Is there some nice study with comparison and analyze of the "randomness" patterns of various libraries? What are the overall methods to analyze the even distribution, yet randomness.. ?

orz
Member #565
August 2000

I'm not much of a fan of GSL, at least for RNG purposes:

1. I suppose you could list "open source" as a strength for it, but there's hardly any RNGs that aren't open source, and GSL has one of the most restrictive licenses out there for an RNG library (it's GPL; a lot of other RNG implementations are free for use even in closed source or non-viral software).

2. Its RNGs tend to be slow. The GSL RNG interfaces don't really allow ultra-high-speed RNGs, their algorithm choices tend to favor slow RNG algorithms, and their RNG implementations seem to be slow implementations as well. eg the GSL MT19937 implementation is 40% slower than my polymorphic MT19937 and 60% slower than my non-polymorphic MT19937 implementation.

3. Its recommended RNGs have various irregular output ranges, some of which are not even powers of 2, let alone nice powers of 2 like 2^8, 2^16, 2^32, or 2^64.

It does have some advantages of course - for instance GSLs support for various random number distributions is way better than mine, and their RNG algorithms tend to have better understood mathematical structures.

************************
edit:
type568:
Broadly methods of analysis fall in to two categories:
A. Theoretical analysis & proofs: basically, attempt to do mathematical proofs about the algorithms. The limitation is that only the simplest of algorithms can be analyzed unless the algorithm was specifically designed around the intended path of analysis. And any proof tends to be very limited in the scope of what it can say.
B. Empirical analysis: Basically, run the RNG and examine the output. The limitation is that only the simplest of flaws can be found. And it's not entirely clear how significant any flaw found really is to real world RNG users.
Though some methods are sort of hybrids of those two.

There are a number of libraries that perform empirical analysis on RNG output. I prefer my own (named Practically Random, see the link above) and TestU01. There is a NIST test suite is popular for that purpose, and RaBiGeTe is another entry in the field. There is also a classic named DIEHARD that is badly outdated and should not be used, but is still popular.

type568
Member #8,381
March 2007
avatar

Thanks, downloading NIST..

 1   2 


Go to: