New algorithm for random number generation
05-26-2014, 01:04 AM (This post was last modified: 05-26-2014 06:56 PM by Namir.)
Post: #1
 Namir Senior Member Posts: 690 Joined: Dec 2013
New algorithm for random number generation
I have been tinkering with a set of new algorithms for uniformly-distributed random number generation (RNG). I test each algorithm using several long runs. I test various statistics related to each run of 10000 numbers (such as auto-correlation and various histograms). I end up calculator an empirical "goodness" factor based on these statistics.

Recently I bumped into an interesting algorithm while working with a family of RNGs that use ratios of random numbers generated using simpler/basic methods. I noticed the following:

Code:
 1. Generate r1 (between 0 and 1) using basic RNG algorithm #1 2. Generate r2 (between 0 and 1) using basic RNG algorithm #2 3. Calculate R -= r1/r2 4. If R > 1 then R = 1/R 5. If R = 1 then R = 0 6. Return R as a random number

I noticed that the above algorithm often generates better random number than the underlying basic RNG algorithms.

I will publish (on my web site) my tinkering in a few week.

Namir

PS: You have some flexibility in choosing the basic algorithms in steps 1 and 2.
05-26-2014, 04:00 AM
Post: #2
 Garth Wilson Senior Member Posts: 377 Joined: Dec 2013
RE: New algorithm for random number generation
If the random numbers are needed at random times, you can involve a reading of the timer as part of the algorithm. The word TIME on the HP-71 gives seconds since midnight, with .01s resolution.

05-26-2014, 04:04 AM
Post: #3
 Paul Dale Senior Member Posts: 1,561 Joined: Dec 2013
RE: New algorithm for random number generation
Times are usually a bad idea in random number generators.
Time isn't very random and it destroys any repeatability.

Seeding using time as a component needn't be such a bad thing.

- Pauli
05-26-2014, 06:53 PM (This post was last modified: 05-26-2014 06:54 PM by Namir.)
Post: #4
 Namir Senior Member Posts: 690 Joined: Dec 2013
RE: New algorithm for random number generation
I have designed[/b] RNGs using virtual clocks and virtual timers. Each time you call the RNG of these types, the clock/timer ticks forward by one virtual second. This makes the code independent of the underlying system's clock speed. Using virtual clocks and timers you can define the range of seconds, minutes, hours, days, and months to YOUR LIKING and not be forced to use conventional ranges.

Namir
06-06-2014, 01:31 AM
Post: #5
 ttw Member Posts: 187 Joined: Jun 2014
RE: New algorithm for random number generation
Note that if the input RNGs are uniform over (0-1) then the output isn't. This method is useful in generating Gaussians and the like by sampling from a restricted domain followed by rejection. It goes by the name "ratio uniforms method."
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)