RAND48
48-bit Random Number Generators


RAND48 is a C library which demonstrates the use of several stdlib functions, which uses 48-bit arithmetic to generate uniformly distributed pseudorandom value. The results can be returned as double precision values in [0.0,1.0], or as long integers in [-2^31,2^31], or as nonnegative long integers in [0,2^31].

The underlying calculations are done in 48-bit integer arithmetic. The user has the option of allowing the system to select the initial seed, or of supplying 32 bits of the seed as a long int, or supplying all 48 bits of the seed as 3 16 bit values. The user can also supply the seed as an explicit argument on each call, or make a single initialization call with the desired seed.

Routines to set the seed:

There are 3 routines available which return a random value, assuming that the seed has been set in advance by a call to srand48, seed48, or lcong48, or that the user is satisfied with a default seed value. These routines have no input argument.

There are 3 routines available which return a random value, whose computation is determined by the value of the seed vector in the input argument. These routines do not require the user to call a seed initialization routine first.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

RAND48 is available in a C version and a C++ version.

Related Data and Programs:

ASA183, a C library which implements the Wichman-Hill pseudorandom number generator.

C_RANDOM, C programs which illustrate the use of C's random number generator routines.

FAURE, a C++ library which computes elements of a Faure quasirandom sequence.

HALTON, a C++ library which computes elements of a Halton quasirandom sequence.

HAMMERSLEY, a C++ library which computes elements of a Hammersley quasirandom sequence.

NIEDERREITER2, a C++ library which computes elements of a Niederreiter sequence using base 2.

NORMAL, a C library which computes elements of a sequence of pseudorandom normally distributed values.

RANLIB, a C library which produces random samples from Probability Density Functions (PDF's), including Beta, Chi-square Exponential, F, Gamma, Multivariate normal, Noncentral chi-square, Noncentral F, Univariate normal, random permutations, Real uniform, Binomial, Negative Binomial, Multinomial, Poisson and Integer uniform, by Barry Brown and James Lovato.

SOBOL, a C++ library which computes elements of a Sobol quasirandom sequence.

UNIFORM, a C library which computes elements of a sequence of pseudorandom uniformly distributed values.

VAN_DER_CORPUT, a C++ library which computes elements of a 1D van der Corput sequence.

Reference:

  1. Donald Knuth,
    The Art of Computer Programming,
    Volume 2, Seminumerical Algorithms,
    Third Edition,
    Addison Wesley, 1997,
    ISBN: 0201896842,
    LC: QA76.6.K64.

Examples and Tests:

You can go up one level to the C++ source codes.


Last revised on 18 August 2008.