Homework 2

Introduction

You will implement a general-purpose linear congruential generator (LCG) function. You will compare the LCG using two specific initial settings against the default U[0,1) random number generator supplied by the Random library of your programming language (which may or may not have used a LCG). For each setting, you will generate a stream of pseudo-random numbers in the range [0, 1) (i.e. between 0 and 1, including 0, excluding 1). You should test each stream for uniformity and independence by applying four statistical tests:

  1. Kolmogorov-Smirnov Test
  2. Chi-Square Test
  3. Runs Test
  4. Autocorrelations Test

Finally, you will analyze and present your findings in a well-written, well-organized report.

Program Specifications

You may develop your program Java, C, C++, C#, Python, or a language of your choice (pending approval of the TA). Your program should provide some reasonable input prompts for the user (i.e., the TA), and its output should be stored and/or displayed in some reasonable way. For example, the program should ask the user to select a function setting to generate random numbers, how many numbers to generate, etc.; it should ask the user to select a statistical test to run; it should save the stream of generated numbers to a file rather than let them scroll across the screen.

You should prepare a README file (separate from the analysis report) for the grader. It should explain how to run your program and provide any other relevant information that might help the grader evaluate your program.

Generation Function Settings

Choose the same seed (X0) for all three cases (for example, X0=123456789). You should specify the seed value you used in the report.

  1. The standard random number generator for your programming language.
  2. Your implementation of the LCG using the following initial setting:
  3. Your implementation of the LCG using the RANDU initial setting

Statistical Tests

You will check for uniformity and independence of the numbers generated by the three methods above by applying the following statistical tests. You should check for significance at the 80%, 90%, and 95% level. Note that some tests are one-sided while others are two-sided.

  1. Chi-Square Frequency Test for uniformity
  2. Kolmogorov-Smirnov Test for uniformity
  3. Runs Test for independence
  4. Autocorrelations test for independence

Write-Up / Analysis

Once you have done all of your tests, you must look over and analyze your results and present them in a well-written, well-formatted report. Your report should include a discussion of the following:

Submission and Grading:

The assignment is due Wednesday, February 17 by 11:59 pm.

Zip your source code files, your write-up, and your README into one zip file and upload it to CourseWeb, in the Homework 2 location.

For more advice on submitting your assignment, see the Assignments section of the Tips for Success page.