I assume you are working with floating point numbers. Using Weyl's Theorem, pick any irrational number I. Pi and Phi are convenient on my computer, but it does not have to be transcendental, Sqrt(2), the oldest known irrational, will work OK. Pick any seed x between 0 and 1. The next random number is just x' = x + I modulo 1. In WP-34s code of my handheld, this would be
LBL 99
RCL 98
RCL+99
FRC
STO 99
RTN
The initial seed is pre-stored in register 99 and the addend is pre-stored in register 98. This code reflects the fact that on my computer things run faster when stack lift is minimized.
It is lightning fast and uses only two registers: one for the seed and one for the addend. XEQ 99 from the keyboard or in the code of your application will put a random number onto the stack. This code leaves the random number on the stack and does not lift the stack at all in computing the random number. Register 99 holds the seed and register 98 is pre-loaded with the irrational. (Yes, I know, the irrational is not exactly represented in computer memory, but it's close enough for gubbermint work). It is fast as lightning and uses only two registers out of the 99 in my computer. The last random number generated is always available in register 99 if you should need to re-use it. It is so simple, you can easily code it into the computer language of your choice. I use it in Excel VBA ***, for example.
The period is unknown, probably beyond the ability of my computer to measure. The distribution of resulting values is highly uniform. I have tested it with the chi square test 90 bins, and also the comb test with comb factor 1000 and 90 bins with Phi as the addend, and it gets ridiculously low chi square scores even with sample sizes in the bazillions.
Alas, you know what to expect when things are too good to be true! You can NOT use this to generate random pairs or triples, or higher order sets because each result is strongly dependent on its precursor. For higher dimensions, you must use a separate RNG for each dimension, and the addends must differ to avoid undesired correlations between successive random numbers. I have tested this for up to three dimensions, and found the triples from three independent RNG's to be highly independent and very uniform in the 3-cube.
Confession 1: I have done extensive testing and have still not broken the RAN# function that is built into my computer.
Confession 2: The exact set of random numbers you get depends on your platform due to differences in word length, number representation (binary or decimal), and other factors.
*** The creators of Excel VBA are to be awarded the Admiral Grace Brewster Hopper award for excellence in program language technology.
time()
, or trig functions? – Disaccustom