Mth 4135 homework - write code that performs this


Homework -

George Marsaglia's Diehard tests are a battery of statistical tests to test the quality of a random number generator (RNG). In this assignment, we will run one of the tests.

The test proceeds as follows: take a cube of size 1000 x 1000 x 1000, and use your RNG to produce 4000 points uniformly distributed throughout this cube. Out of these 4000 points, find the two points that are closest to one another, distance being measured by the usual Euclidean metric. Let r be the distance between these two points, and let V = 4/3πr3. (So V is the volume of the largest sphere which is centered at one of the 4000 points, and which does not contain any of the other points in its interior.)

The variable V should be very close to being exponentially distributed with mean 40π.

Task - Write code that performs this simulation, using each of the following uniform generators (code for which can be found in the template .cpp file that I have provided):

  • the RANDU generator;
  • the LCG with a = 22695477; c = 1; m = 232;
  • and the Mersenne Twister.

For each of the three generators, run this simulation 10,000 times. This should produce 10,000 values of V: output each of those 10,000 values into a text file, with a different number on each line. (Use a different file for each of the three generators.)

I have provided starter code in the file sphere template.cpp (see below if you feel more comfortable using Python).

Need code in python.

Attachment:- Assignment Files.rar

Request for Solution File

Ask an Expert for Answer!!
Advanced Statistics: Mth 4135 homework - write code that performs this
Reference No:- TGS02787580

Expected delivery within 24 Hours