Java Randomness Test Suite

Home
Tests
Algorimths
FAQ
JavaDoc
Mailing List
Change Log
Contact
License
Links
Contribute
CVS
JRandTest at SourceForge
SourceForge Logo

List of tests

BinaryRankTestFor31x31Matrices test

This is the Binary Rank Test for 31x31 matrices. The leftmost 31 bits of 31 random integers from the test sequence are used to form a 31x31 binary matrix over the field {0,1}. The rank is determined. That rank can be from 0 to 31, but ranks< 28 are rare, and their counts are pooled with those for rank 28. Ranks are found for 40,000 such random matrices and a chisqu- are test is performed on counts for ranks 31,30,28 and <=28.

BinaryRankTestFor32x32Matrices test

This is the Binary Rank Test for 32x32 matrices. A random 32x 32 binary matrix is formed, each row a 32-bit random integer. The rank is determined. That rank can be from 0 to 32, ranks less than 29 are rare, and their counts are pooled with those for rank 29. Ranks are found for 40,000 such random matrices and a chisquare test is performed on counts for ranks 32,31, 30 and <=29.

BinaryRankTestFor6x8Matrices test

This is the Binary Rank Test for 6x8 matrices. From each of six random 32-bit integers from the generator under test, a specified byte is chosen, and the resulting six bytes form a 6x8 binary matrix whose rank is determined. That rank can be from 0 to 6, but ranks 0,1,2,3 are rare; their counts are pooled with those for rank 4. Ranks are found for 100,000 random matrices, and a chi-square test is performed on counts for ranks 6,5 and (0,...,4) (pooled together).

BirthdaySpacings test

This is the Birthday Spacings Test. Choose m birthdays in a "year" of n days. List the spacings between the birthdays. Let j be the number of values that occur more than once in that list, then j is asymptotically Poisson distributed with mean m^3/(4n). Experience shows n must be quite large, say n>=2^18, for comparing the results to the Poisson distribution with that mean. This test uses n=2^24 and m=2^10, so that the underlying distribution for j is taken to be Poisson with lambda=2^30/(2^26)=16. A sample of 200 j's is taken, and a chi-square goodness of fit test provides a p value. The first test uses bits 1-24 (counting from the left) from integers in the specified file. Then the file is closed and reopened, then bits 2-25 of the same integers are used to provide birthdays, and so on to bits 9-32. Each set of bits provides a p-value, and the nine p-values provide a sample for a KSTEST.

Count1Bit test

This is part of the Count Test. It counts the bits, 0's and 1's. The sums and the differences are reported. The expection is 50%, each sum from total bits.

Count2Bits test

This is part of the Count Test. It counts consecutive 2 bits. The sums and the differences are reported. The expection is 25%, each sum from total 2 bits.

Count3Bits test

This is part of the Count Test. It counts consecutive 3 bits.

Count4Bits test

This is part of the Count Test. It counts consecutive 4 bits. The sums and the differences are reported. The expection is 1/16, each sum from total 4 bits.

Count8Bits test

This is part of the Count Test. It counts consecutive 8 bits. The sums and the differences are reported. The expection is 1/256, each sum from total 8 bits.

Count16Bits test

This is part of the Count Test. It counts consecutive 16 bits.

CountThe1s test

This is the Count-The-1's Test on a stream of bytes. Consider the file under test as a stream of bytes (four per 32 bit integer). Each byte can contain from 0 to 8 1's, with probabilities 1,8,28,56,70,56,28,8,1 over 256. Now let the stream of bytes provide a string of overlapping 5-letter words, each "letter" taking values A,B,C,D,E. The letters are determined by the number of 1's in a byte: 0,1,or 2 yield A, 3 yields B, 4 yields C, 5 yields D and 6,7 or 8 yield E. Thus we have a monkey at a typewriter hitting five keys with various probabilities (37,56,70,56,37 over 256). There are 5^5 possible 5-letter words, and from a string of 256,000 (overlapping ) 5-letter words, counts are made on the frequencies for each word. The quadratic form in the weak inverse of the covariance matrix of the cell counts provides a chisquare test: Q5-Q4, the difference of the naive Pearson sums of (OBS-EXP)^2/EXP on counts for 5- and 4-letter cell counts.

CountThe1sSpecificBytes test extends CountThe1s

with rt=24

DNA test extends OverlappingPairsSparseOccupancy

with bits_pl = 2 std = 339.0 The DNA test considers an alphabet of 4 letters: C,G,A,T, determined by two designated bits in the sequence of random integers being tested. It considers 10-letter words, so that as in OPSO and OQSO, there are 2^20 possible words, and the mean number of missing words from a string of 2^21 (overlapping ) 10-letter words (2^21+9 "keystrokes") is 141909. The standard deviation sigma=339 was determined as for OQSO by simulation. (Sigma for OPSO, 290, is the true value (to three places), not determined by simulation.

MinimumDistance test

The Minimum Distance Test. It does this 100 times: choose n=8000 random points in a square of side 10000. Find d, the minimum distance between the (n^2-n)/2 pairs of points. If the points are truly independent uniform, then d^2, the square of the minimum distance should be (very close to) exponentially distributed with mean .995 . Thus 1-exp(-d^2/.995) should be uniform on [0,1) and a KSTEST on the resulting 100 values serves as a test of uni- formity for random points in the square. Test numbers=0 mod 5 are printed but the KSTEST is based on the full set of 100 random choices of 8000 points in the 10000x10000 square.

MonteCarlo test

This is the Monte Carlo Test. We read 16 bits as X, and 16 bits as Y. If (X,Y) point in circle(256) we count success. piValue is (success / num_of_points) * 4.

Overlapping20TuplesBitstream test

The Bitstream Test. The file under test is viewed as a stream of bits. Call them b1,b2,... . Consider an alphabet with two "letters", 0 and 1 and think of the stream of bits as a succession of 20-letter "words", overlapping. Thus the first word is b1b2...b20, the second is b2b3...b21, and so on. The bitstream test counts the number of missing 20-letter (20-bit) words in a string of 2^21 overlapping 20-letter words. There are 2^20 possible 20 letter words. For a truly random string of 2^21+19 bits, the number of missing words j should be (very close to) normally distributed with mean 141,909 and sigma 428. Thus (j-141909)/428 should be a standard normal variate (z score) that leads to a uniform [0,1) p value. The test is repeated twenty times.

OverlappingPairsSparseOccupancy test

OPSO means Overlapping-Pairs-Sparse-Occupancy. The OPSO test considers 2-letter words from an alphabet of 1024 letters. Each letter is determined by a specified ten bits from a 32-bit integer in the sequence to be tested. OPSO generates 2^21 (overlapping) 2-letter words (from 2^21+1 "keystrokes") and counts the number of missing words---that is 2-letter words which do not appear in the entire sequence. That count should be very close to normally distributed with mean 141,909, sigma 290. Thus (missingwrds-141909)/290 should be a standard normal variable. The OPSO test takes 32 bits at a time from the test file and uses a designated set of ten consecutive bits. It then restarts the file for the next designated 10 bits, and so on.

OverlappingQuadruplesSparseOccupancy test extends OverlappingPairsSparseOccupancy

with bits_pl = 5 std = 295.0 OQSO means Overlapping-Quadruples-Sparse-Occupancy. The test OQSO is similar, except that it considers 4-letter words from an alphabet of 32 letters, each letter determined by a designated string of 5 consecutive bits from the test file, elements of which are assumed 32-bit random integers. The mean number of missing words in a sequence of 2^21 four- letter words, (2^21+3 "keystrokes"), is again 141909, with sigma = 295. The mean is based on theory; sigma comes from extensive simulation.

Run test

This is the Runs Test. It counts runs up, and runs down, in a sequence of uniform [0,1) variables, obtained by floating- the 32-bit integers in the specified file. This example shows how runs are counted: .123,.357,.789,.425,.224,.416,.95 contains an up-run of length 3, a down-run of length 2 and an up-run of (at least) 2, depending on the next values. The covariance matrices for the runs-up and runs-down are well known, leading to chisquare tests for quadratic forms in the weak inverses of the covariance matrices. Runs are counted for sequences of length 10,000. This is done ten times. Then another three sets of ten.

Squeeze test

This is the Squeeze Test. Random integers are floated to get uniforms on [0,1). Starting with k=2^31-1=2147483647, the test finds j, the number of iterations necessary to reduce k to 1, using the reduction k=ceiling(k*U), with U provided by floating integers from the file being tested. Such j's are found 100,000 times, then counts for the number of times j was <=6,7,...,47,>=48 are used to provide a chi-square test for cell frequencies.

View Class Hierarchy [new window] page for all packages, plus a hierarchy for each package.

Copyright © 2005 Zur Aougav
aougav@hotmail.com
All rights reserved
Last modified: Wed Apr 20 21:36:38 2005