(9817) Random Number Functions, Algorithms?

Archive of the OpenVMS Ask the Wizard (ATW) questions and answers database.
Locked

Topic author
User
Visitor
Posts: 0
Joined: Mon Jan 10, 2022 8:16 am
Reputation: 0
Status: Offline

(9817) Random Number Functions, Algorithms?

Post by User » Thu Sep 09, 2004 9:26 am

rand() function callable by C or FORTRAN.
Has the random number generator embedded within OpenVMS ever been certified by
an independednt organization? If so, who?

Question is asked because of a proposal our company is responding to. The
customer requires independent certification of any RNG employed. Thanks!


Wizard
Visitor
Posts: 0
Joined: Mon Jan 10, 2022 8:17 am
Reputation: 0
Status: Offline

Re: (9817) Random Number Functions, Algorithms?

Post by Wizard » Fri Sep 10, 2004 9:26 am

The underlying (pseudo) random number generator for most random-number
requests MTH$RANDOM. It uses a mixed congruential algorithm:

Seed = (69069 * seed +1) MOD 2**32

This algorithm is as described in the literature, most notably in Knuth
"The Art of Computer Programming", Volume 2 "Seminumerical Algortithms"

The choice of multiplier is taken from

"Random Number Generation" by G. Marsaglia in:
Encyclopedia of Computer Science (pp. 1192-1197)
edited by Anthony Ralston, Petrocelli (New York, 1976)

As with all algorithms, this method is a compromise between speed of
execution and the quality of the generated pseudo random sequences.
There are numerous papers in the literature which perform deep
statistical analysis of various choices of algorithm. This particular
choice has stood the test of time and remains the best choice in its
class for a general purpose uniform distribution generator. It's very
fast and produces quite good sequences of numbers.

A Google search for "MTH$RANDOM" finds plenty of references. A full
literature search may find more (academic statisticians love to pick
holes in commercial random number generators).

There are some applications which require "better" random sequences
("better" defined as passing more stringent statistical tests of
randomness). There are algorithms which satisfy these critera, but
they require more computation, and are therefore slower.

If you have a special requirement for pseudo random number generation,
you should replace the standard generator. There are huge numbers of
algorithms available either commercially or published in the literature.
It's just a matter of selecting one that satisfies your exact needs.

Specifically with the C rand() function, the algorithm is documented
as:

static unsigned int next = 1;
int rand(void)
{
next = next * 1103515245 + 12345;
return (next & RAND_M
}

The actual implementation of rand() is slightly complicated, given
the need for reentrancy.

Locked