Uniform Random Numbers

This source code is for Borland Delphi (Object Pascal), it should load and compile cleanly in most versions of the IDE. It was written using the Borland IDE, and tested numerous times in production programs of both my own and others. If you use any of this and find a bug, or just want to tell me it was useful, please contact me to tell me about it.

Relevant Links

Uniform Random Numbers

The Uniform Random Number unit contains a Delphi code unit with example program to generate and plot random numbers in a uniform distribution. If you need some random data within a particular set of parameters, and want it uniformly distributed between a minimum and maximum, here you go. It's best to use this method for generating test data, or filling databases with random stuff for debugging purposes.

Methods

After trying the Mersenne Twister method, various other random number generation methods, and a few of my own, I found a paper and some source code based on a method originally outlined in a paper submitted to the Association for Computing Machinery. I did some modifications and cleanup to the code, put it in a unit, and here it is, along with a small demo program to visualize the distribution of the numbers. The original source code and paper are credited in the unit. For uniformity, I found this method to be superior to the Mersenne Twister algorithm.