This is a test that virtually all random number generators, good, bad, or indifferent, will pass. Divide up the range of output values into a fixed number of intervals (101 for the results presented here) of equal size. Generate a large number of values using random() (we used 1,000,000) and count the number of values that fall in each interval. Since the intervals are of equal size, approximately the same number of values (about 10,000) should fall in each interval. Calculate the chi-square statistic based on the actual and expected counts for each interval, and compare with the critical value for a chi-square random variable with 100 degrees of freedom and a probability of 0.95.
Return to the testing home page.