Random Numbers ...

Herman Rubin cik at l.cc.purdue.edu
Sun Feb 28 22:58:05 AEST 1988


(This doesn't belong in comp.lang.c, but too much has already been posted).
I would never use a pseudo-random procedure for any job of any importance.
However, let me make some suggestions about good, cheap procedures.  

First, do not make a subroutine call for each random number wanted.  Use a
buffer!

Second, get some physical random bits.  And make sure that all bits are
random.

Third, probably you should want your initial random numbers to be words of
random bits.  Keep away from floating point or positive random numbers.

A fairly good combination of physical and pseudo-random numbers is to
have a pseudo-random procedure which uses a long word-shift-register
algorithm such as   
	
	x[i] = x[i-460] XOR x[i-607];

One could replace XOR by + if addition is full-word two's complement.

Then one should make the used random variables 

	y[i] = x[i] XOR z[i],

where the z's are physical random numbers.  For a large job, the z's have
to be recycled.  The length of the physical random number file should not
be too close to a rational number with small numerator and denominator
times a power of 2.

Even using the pseudo-random numbers alone with a 607-word physical random
seed is likely to be much better than anyting else posted here.   A major
reason for using physical random numbers is that a pseudo-random scheme
is likely to have unknown regularities, which the physical random numbers
are unlikely to match; a good reason to include the pseudo-random numbers
is to guarantee uniformity; one cannot trust the physical random numbers
that much.

With a good seed, the procedures suggested by Shamir and by Blum and
Miccaeli might even be better, but they are very expensive. 
-- 
Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907
Phone: (317)494-6054
hrubin at l.cc.purdue.edu (ARPA or UUCP) or hrubin at purccvm.bitnet



More information about the Comp.lang.c mailing list