rand48_test a C++ code which uses the rand48 function in the C stdlib library. The rand48 function uses 48-bit arithmetic to generate uniformly distributed pseudorandom values. 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.
The computer code and data files described and made available on this web page are distributed under the MIT license
rand48_test is available in a C version and a C++ version.
ASA183, a C++ code which implements the Wichman-Hill pseudorandom number generator.
CPP_RANDOM, C++ codes which illustrate the use of the C++ random number generator routines.
FAURE, a C++ code which computes elements of a Faure quasirandom sequence.
HALTON, a C++ code which computes elements of a Halton quasirandom sequence.
HAMMERSLEY, a C++ code which computes elements of a Hammersley quasirandom sequence.
NIEDERREITER2, a C++ code 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++ code 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++ code which computes elements of a 1D van der Corput sequence.