 Home Chemistry Physics Mathematics Bio Chemistry Plant Biology Aerodynamics Zoology Energy Science Product Science Science Experiments Kids Projects Contact Us

# Generating Random Numbers

The Objective

This project tested three random number generators (functions in Excel, C++, and Java) and evaluated the results using chi-square values from each experiment to determine which program was most likely to generate unbiased random numbers. My hypothesis was that C++ was most likely to generate unbiased random numbers because this language is used to construct many computer programs and games which require a random number generator.

Methods/Materials

Random number functions in Microsoft Excel 2002, C++ (Borland C++), and Java (Microsoft J 2005 express edition) were tested.

Random numbers generated by each program were converted to integers between 0 and 9.

When converting the random numbers to integer values care was taken to round the generated values in an equivalent manner to prevent bias.

Each program was used to generate sets of 10, 100, 1,000, and 10,000 random numbers.

The sets of random numbers (10, 100, 1,000, and 10,000) were generated five times with each program.

Results

For each experiment the measured frequencies were compared with the expected frequencies (10% of the total integers generated in each experiment).

Chi-square tests were used to evaluate if each program was likely to be generating independent and unbiased random numbers.

From the chi-square test results calculated for each experiment it was found that each program tested was likely to be generating unbiased random numbers.

Conclusions/Discussion

From the chi-square test results calculated for each experiment it was found that each program tested was likely to be generating unbiased random numbers. For larger sample sizes (1,000 and 10,000 random numbers) it was found that Excel was the most likely to generate unbiased random numbers.

This project tested three random number generators (functions in Excel, C++, and Java) and evaluated the results using chi-square tests to determine which program was most likely to generate unbiased random numbers.

Science Fair Project done By Paul M. Mayer