Sunday, January 22, 2006

Tests on random numbers

If someone (such as a random number generator) claims a set of numbers to be random numbers, following some probability distribution, most commonly, uniform, there are certain tests that can be performed on these random numbers to ascertain or deny this claim. Such tests include Kolmogorov-Smirnov test, Chi-square test, Poker test, Gap test, Runs test. There are also some batteries of tests such as the Diehard battery of tests, that can be performed on the set of random numbers. The results of these tests can be analyzed to accept or deny the claim.
We were asked to perform these tests on the random numbers generated through Microsoft Excel and Matlab. Here is everything, including the Excel workbook to perform the tests on Excel random numbers as welll as a workbook to perform the tests on Matlab random numbers. Different worksheets correspond to each test. Macros have been written to perform and repeat these tests on 100 sets of 100 random numbers. Matlab includes a command called xlswrite() to export some Matlab variable to excel.
Also included is the C# program to export random numbers from Excel to a binary mode file for the DieHard battery of tests using Office Interop. Apart from that, there is a Visual C++ program to export random numbers from Matlab into a binary mode file for the same purpose. Test results from the Diehard battery are also included, as is an MS Word document that summarises and analyzes the results.

No comments: