Problem 30

This is the archived version of this course from the Spring 2013 semester. You might find something more recent by visitning my teaching page.

Universal PRNG

Due: February 22
Points: 2 FOR ALL

SPECIAL: If anyone in the class completes and submits this program, everyone will earn 2 points. The idea is that this is a collaborative class-wide project to some extent. You should still list the names of everyone in the class who worked on the project when you submit.

Write a Java, C++, or Python program that generates random numbers using any one of the PRNGs we discussed in class:

  • Lehmer LCG with prime modulus
  • Mixed LCG with power-of-2 modulus
  • Linear recurrence LFSR with m=2
  • Mersenne Twister

Your program will need to include all 4 capabilities at once. By default, the program should use the Linear recurrence generator to generate 500 numbers from 0 up to \(2^16-1\). However, optional command-line flags should be possible to specify:

  • Which PRNG to use among those 4 listed
  • How many numbers to generate (one per line)
  • How large the generated numbers should be (any value up to \[2^31-1\], and your outputs should be between 0 and that number).
  • What seed value to use. (If none specified, use /dev/urandom.)

There should be a "help" flag -h that lists these options and how they are specified.

You should choose the parameters for the PRNGs based on what values actually get used in practice to give periods as long as possible and generate numbers in the range that you will need. Ask Dr. Roche if you need any help!