[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Nearly finished (re)integrating GMP for bignums.
From: |
Mikael Djurfeldt |
Subject: |
Re: Nearly finished (re)integrating GMP for bignums. |
Date: |
Wed, 12 Feb 2003 18:34:59 +0100 |
User-agent: |
Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu) |
Marius Vollmer <address@hidden> writes:
>> With respect to random.c, we have a pluggable random number system,
>> and ATM the bignum randoms are computed using the
>> "get_32_random_bits()" function provided by the random state object.
>> However GMP has its own random number generators, including ones for
>> bignums. Any thoughts on how we should handle this?
>
> I think we should use the GMP generators unless they are not as good
> as ours. But I doubt that.
This is actually a little tricky. I'd like to bring up two points
about this issue:
1. Marius, do you suggest to use the GMP generators as a source of
random bits for random.c, that is to "plug in" the GMP generator as
a replacement for scm_i_uniform32?
That would be OK, but using scm_i_uniform32 "in parallel" with the
GMP generators would probably not be.
It is a dangerous mistake to use multiple pseudo-random generators
within the same application, the reason being that while each
generator on its own will have an extremely long cycle in its
number series, interference between the series can give
deterministic behavior. For example, the difference between the
outputs of two generators might have a short cycle. Interference
can occur in any number of strange ways if two generators
simultaneously affect the same program.
2. What do you mean by a "good" RNG? I'd say it is good if it is
fast. Our generator is fast. Can you name any single other
criterion which is not "religious" and which our generator doesn't
fulfil? (I'm talking about something measurable here.)
I'm no expert in RNG:s, but when doing research before writing
random.c I couldn't find any arguments against using the current
MWC generator. As stated in a commentary in random.c, it has a
cycle length of 4.6e18 and passes all tests in the "DIEHARD" RNG
test suite. At any rate, it should be sufficient for standard
Guile use.
(For those doubting the utility of speed in a RNG, I can only note
that for me it's very important. In my simulation software I often
generate large random matrices and need to have multiple sources of
simulated "noise".)
Ideally, the bignum code would use the pluggable source of random bits
in random.c and the GMP generators would be provided as optional
plugins for random.c. Rob, is this possible?
Mikael