[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pseudo-random numbers



David Skoupil wrote:

> is there a (fast) way in Dr.Scheme to generate random numbers with
> arbitrary upper bound. The implemented random number generator gives
> numbers in the range from 0 to 2^31. I am playing with RSA and I need to
> generate say 100 digits long randoms.

Hm. What do you mean by "fast"?
The manipulation of arbitrarily long numbers is as fast as it
can be, no faster...

You can always implement a simple congruential RN generator
X -> A X + C (mod M) in Scheme using arbitrary A and M, and, of
course, verifying whether your generator is "sane" (a good place
to start is the second volume (Seminumerical algorithms) of Knuth.

Another way is to generate a list of random digits (in any positional
system, e.g. random bits). This is extensively covered by the 
literature as well.

Jerzy Karczmarczuk
Caen, France.