rand48_test


rand48_test, a C code which calls rand48(), 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 MIT license

Languages:

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

Related Data and Programs:

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

c_random_test, C codes 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 code 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 code which computes elements of a sequence of pseudorandom normally distributed values.

RANLIB, a C code 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 code 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:


Last revised on 01 August 2019.