don@allegra.UUCP (Don Mitchell) (03/14/85)
True random numbers are difficult to come by. I spent some time looking into thie question once and talked to a couple of the top EE's in research here. None of them would touch the problem with a ten foot pole! It is pretty easy to get biases noise by amplifying thermal noise or counting radioactive decays. Probably, an expert on coding theory could tell you how to reduce this to some close approximation to uniform noise (something like taking the CRC checksum of a block of biased noise?). A nice way to get biased noise in many computers is to take advantage of the relative jitter between the CPU clock and the 60 Hz line. This method "grabs randomness" from any source it can get. You just set an alarm for 1/60 of a second and then begin incrementing a counter in a fast infinite loop. When SIGALRM comes, save the value of the counter. There is a lot of variation in the value of the counter even when the machine is idle. On a VAX or SUN, it appears that the low two or three bits are quite random. (It looks like more bits are random, but not if you do some statistics.) Keep in mind, this noise is biased. If you just want a random seed for something, xor the access dates of a bunch of commonly-touched files like /bin/ls and /bin/sh, etc.