home *** CD-ROM | disk | FTP | other *** search
- I wrote this package to overcome some troubles I had with the random()
- package. I had been saving random()'s state table to a disk file, then
- restarting the random sequence in the next program run. I discovered some
- seriously non-random behavior in the numbers resulting from this practice.
- Further investigation (including examination of the object code for
- random() -- painful!) showed me that it is necessary to count the number of
- calls to random() in order to safely restart it. Hence the enclosed code.
-
- I believe random(), with my modifications, is superior in many respects
- to its competition within 4.3bsd Unix, namely rand() and rand48().
- Those generators are based on a multiplicative congruential scheme,
- which makes them difficult to use in applications where one is generating
- points uniformly distributed on the unit square. Certainly rand() has
- the problem that a high-resolution 2-d plot of the x-y points generated by
- for (i=0; i<n; i++) {
- x[i] = rand()/MAXLONG;
- y[i] = rand()/MAXLONG;
- }
- will show stripes. Using rand()%m is suicidal, since its low-order bits
- are known to be cyclic. Perhaps I'm selling rand48() short, since I haven't
- examined it in detail: quite possibly its constants were chosen to minimize
- the separation between the stripes in a 2-d plot.
-
- To help you get started, I have also enclosed a test-driver called mrtest.
-
- Please let me know if you find any defects in the sequence generated
- by the default seed built into mrtest. I picked that seed for
- sentimental reasons: it was the last number generated by my old,
- and now discredited, random() sequence.
-
- Clark Thomborson
- cthombor@gw.d.umn.edu
-