Skip to end of metadata
Go to start of metadata

Random Number Generation

 Purpose

       This page is meant to help programmers with random number generation inside of their code, for use in simulations and on work requiring the use of clusters.So far I am only attaching a nice guide about generating numbers randomly using a simple algorithm called KISS. The article also gives some nice tips on generating random numbers. I do need some more time to flesh out this page with ideas.

 Article for tips.

 Terms

Period - Gives the actual length of random numbers a random number generator can produce.

Pseudo-random number generation - Usually a long lengthy sequence of random numbers which can be repeatedly generated by use of an initial "seed."

Seed - An initial value given to a psuedo-random number generator that specifies the starting point in a sequence of randomly generated numbers.

Parrallel Random Number Generation - Usually refers to a different set of random number generation methods for use in parralell written programs involving threads, and jobs.

Diehard tests - A battery of statistical tests for measuring the quality of a  random number generator. They were developed by George Marsaglia over several years and first published in 1995 on a CD-ROM of random numbers.

 Programming Software Libraries

 This section contains information and opinion on the use of random number generation libraries. These libraries can be in different languages.

RDieharder - This R library offered a way for one to test their random number generation method, by supplying their function as an argument to one of the Dieharder random number tests. 

  • This library offered really good flexibility for testing your function. IE the advertisement is:
    dhtest <- dieharder(rng="randu", test=10, psamples=100, seed=12345)
  • Link to the web page for the library
  • Last updated 2007...
  • The library had problems installing, since some of the code was written in C. Not the only one doing this, so the library is a bit too much to install now.
  • Library is only in .tar.gz format.
    • Try another library RNG library?

RANDOM R - R library. The author of this library claims to generate real actual random sequences, instead of pseudo-random ones.

  • The random numbers are generated based on measuring how particles move in some kind of decay experiment.
  • This supposedly guarantees that the random number generation is random instead of pseudo-random.
  • Author tested the RANDOM package using the dieharder battery of tests. Mostly passed except for the lack of a large enough period.
  • Primitive random number generation.
    • Can only generate integers, and those integers grabbed from the random.org website can be repeated.
  • First random number string generator I have seen.
    • Can generate random strings of letters using the "randomStrings" function.
  • Very few functions to use, but again insures a different level of random number generation quality that is not "pseudo"
  • Article describing the package, and their testing.

Would like to see some Java libraries.

Testing Random Number Generators

 This section discusses testing of random number generators in more detail. There is a large body of literature and interesting methods devoted to this area.

Statsitical tests were developed to test a random number generator. The tests mostly revolve around the assumption that the distiribution of the random numbers generatred via an algorithm using the generator has some type of asymptotic distribution.  For example in the birthday random number test, birthdays are picked and the distances between the picked birthdays are measured. The distribution of the spacings should follow an asymptotic exponential distribution.

DieHarder - Link -  Robert G Brown has developed a larger test battery based on the original diehard tests. It is now a source of code that can be compiled and then can read in numbers generated from another random number. It will in essence allow someone to test their own random number generator. However this seems to involve some knowledge of compiling projects in unix/linux to use, and I'm not sure how to install it. Could use some help here.

Monkey Test - Article - One of the original tests for software unit testing is a monkey test. This is where you feed a piece of code random input and hopefully one's code will handle it.  There is an actual computer theoretic idea related to the monkey test called "The Infinite Monkey Theorem." - Link . This theorem states that if a monkey is allowed to type on a keyboard an infinite amount of text it will eventually type a given body of work such as Shakespeare's play.

  • As a fun exercise I have implemented a piece of code that does a primitive monkey test for random number generation.
  • The test done is the CAT test.
    • The CAT test lets the random number generator make a random letter A-Z, and we check how many numbers it takes to spell the word CAT
    • Using R 2.10.1, I had about 26154 letters generated to spell cat, then 150156, 229329, 292602, 357945...
      • On the article attached, the author had 18263, then another 14872 later he had a CAT word.
      • The author sited some generators that can't spell certain words as being inefficient, ie old apple computers and radio shack computers
      • My code is committed at: svn://svn.ssg.uab.edu/scratch/ray/Presentations/Random_Numbers

Page History

May 26 2010 - Adding in some more information I found on the RDiehard library. Going to try and use RANDOM R library as well, and see it's utility for random number generation.

May 27 2010 -  Adding in information on monkey test and code.

 

Labels
  • None