Generating Random Numbers

CSEF · 2008 Mathematics & Software

Overview

Objectives/Goals 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.

Summary statement

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.

Help received

Father showed how to use a chi-square distribution table out of a math handbook

Competition history

  • CSEF 2008 Mathematics & Software · Entry J1311

Resources

Related projects

Closest projects by meaning, across every fair and year in the corpus.

Browse more like this

Source: California Science & Engineering Fair public projects

Save projects to your library

Sign in with Google to keep track of projects you find interesting, organized into folders. An account also raises your daily allowance for “Has this been done?”, and lets you create a key for the MCP server with a much higher limit than anonymous use. Browsing stays public.

Continue with Google