Physical Model Tests
It is best to test random number generator in an application similar to where it will be used. We have subjected our generators to ISING model tests and random walk tests. The exact solution for these tests are known, and the tests also have the structure of practical applications. Thus they are good measures of the quality of the generators. We hope that our results will give the computational scientist a measure of the expected biases in the simulation. We explain these test results in this section.
Ising Model Tests
- The Ising model is a model proposed in statistical mechanics that is simple enough that the exact solution is known, but still realistic enough that it has practical applications. In this model, a lattice of spin states is maintained. For each configuration of spin states, it is possible to calculate certain macroscopic properties. Different configurations are generated, and the statistical average of the macroscopic quantity over all the configurations generated is considered the observed value of that quantity. Two popular Monte Carlo algorithms for generating the configurations are (i) the Metropolis Algorithm and (ii) the Wolff Algorithm.
Sequential tests
We present results for these two algorithms with each of our generators for the Specific Heat and the Energy, were we generated around 1011 random numbers in our simulations on a 16x16 lattice.
Parallel tests
We simulated parallelism with the Metropolis algorithm by maintaining a different random number stream at each of the 256 lattice sites. This tests for correlations between streams. The results for the Specific Heat and Energy are given below, with a total of round 1011 random numbers generated.We need to be careful in choosing the seeds. Otherwise correlations between the streams can cause poor results as in the examples shown below. SPRNG users need not bother about this issue, since we automatically handle it in our code.
Test suite
Our current Ising model codes run on a single processor. Even the "parallel" tests are actually serial simulations of a parallel run, in which we use a different random number stream for each lattice site. Users can type: make metropolis or make wolff in order to get the Metropolis or the Wolff algorithm test respectively. The executable has the name metropolis.rng or wolff.rng where rng is the name of the random number generator used. By default, the serial tests are produced. Parallel tests can be generated by defining the macro PARALLEL at the top of the files metropolis.c or wolff.c. These tests take 6 command line arguments: seed param lattice_size block_size discard_blocks use_blocks. For example:mpirun -np 1 metropolis.lcg64 111 0 16 10 10 100
runs the Metropolis algorithm test using the 64 bit Linear Congruential Generator. The seed is 111, the parameter to the generator is 0 (which indicated the default multiplier for the LCG). We use a 16x16 lattice. The simulation performs several sweeps through the entire lattice. We record results of blocks of 10 sweeps. We discard the results of the first 10 blocks (thus a total of 100 sweeps) and then use the results of the next 100 blocks. The last number must be a power of 10. Sample results are shown below:
Metropolis Algorithm with Serial RNG lattice_size = 16, block_size = 10, discard_blocks = 10, use_blocks = 100 64 bit Linear Congruential Generator with Prime Addend seed = 111, stream_number = 0 parameter = 0 Streams are synchronized! Energy Energy_error Sigma_Energy Cv Cv_error Sigma_Cv 0. -1.4737500 0.0206851 0.0465998 1.0225614 0.4761435 0.2184153 1. -1.4819062 0.0288413 0.0141733 1.2165686 0.2821362 0.1030086The important field are the Energy_error which gives the observed error in Energy, and the Sigma_Energy which gives the standard error for the energy. We have similar fields for the specific heat, Cv. The first line is obtained after 10 blocks of data have been averaged. Each subsequent line is the average of ten times the previous run.
Random Walk Tests
- In the Random Walk test, we start a "Random Walker" from a certain position on a two dimensional lattice. The random walker then takes a certain number of steps to other lattice points. The direction of each step is determined from the value returned by a random number generated. A series of such tests are performed, and for each such test, the final position of the random walker is noted. This distribution of positions is compared with the expected distribution with a random number stream from a uniform distribution. A Chisquare value is computed as a quantitative measure of the likelihood of the distribution being uniform.
This test can check for correlations between streams if we interleave streams to form a new stream and run this test. We compared the probability of the random walker being in each of the four quadrants, as in the tests implemented by Vattulainen, et al. Acceptable values were obtained for our generators with 108 random numbers generated, both in the sequential and parallel tests.
Test suite
The first 6 command line arguments for this test are as for the statistical tests. The seventh command line argument is the length of each walk. For example:mpirun -np 2 random_walk.lcg64 2 3 0 0 10 0 100
runs the (parallel) random walk test using the 64 bit Linear Congruential Generator, where we interleave 3 streams at a time to produce a new stream; two such streams being tested. The seed is 0, the parameter to the generator is 0 (which indicated the default multiplier for the LCG). We perform 10 test per stream. Each test uses a walk length of 100.