David,
(I've subscribed to the lisp-hug list, and I'm sending the reply there
in case this discussion is of interest to anyone)
why do you think you need a "very good" generator? In 1998-2000 I
worked on Monte Carlo simulation of physical systems and we actually
used a quit simple shift generator (R250) which was known to have
problems with some clustering algorithms, but was safe for our "local"
algorithm (we really needed something easy to implement, the whole
thing was running on FPGAs) [1]. Lately I've been doing Monte Carlo
again (in finance this time); standard references like Jaeckel [2]
encourage the use of the Mersenne Twister to be on the safe side as
it seems to work well in most circumstances and it's not too demanding
computationally. Glasserman [3] suggest trying a nonlinear generator
(slower) to check everything is ok in case one is concerned about the
quality of the pseudo-random sequence (he refers to a chapter on
"quadratic and inversive congruential PRNG" in [4]). If your
simulation is not affected by the correlation in the sequence at long
distances you should be fine.
However, you mention "all the PRNG's in the simulator" and if you
actually want to use several streams of random numbers things get more
complicated. Using multiple independent generators might not be a good
idea (but depending on your algorithm it might be ok). There are also
solutions to this problem, for example SPRNG [5]. If I remember well,
the same generator (and the same seed) is reused but with different
starting points along the cycle, or leaping over the numbers that are
being generated by the other instances.
(I don't know anything about generators for cryptography, only that in
that case the point is to have a sequence that can't be "predicted";
for simulation you don't care as long as it behaves well in some
statistical sense)
Cheers,
Carlos
[1] I've just found a reference, but I've not read it:
Hi Carlos,
Well, many thanks for your insistence! I thought I had seen
something about that in the last round of release notes... And
this is very good news for the pure-Lisp portions of my code. But
for obtaining variates of Gamma, Nakagami, Rayleigh, and Rice
distributions, there needs to be a C-resident PRNG that can be
called upon by the GSL routines doing the rejection-methods.
And my question was actually three-fold, although I think I now
have the answer to the second part: seeding the MT PRNG is done
with just about any 32-bit integer value, and so I read the
elapsed microseconds in the computer's clock, and logand that
with #xFFFFFFFF. That gives me a random seeding so that not all
the PRNG's in the simulator are running with the same values.
But the final question relates to suitability of the MT PRNG for
use in deriving accurate statistical estimates. I read that the
suitability of various PRNG's varies between this kind of use,
and usage in crypto applications. I haven't seen any good
recommendations either way on any of the available PRNG's --
though I suspect folks at the NSA know which ones to use for
crypto...
So thanks a bunch for pointing that out about LW !!
Cheers,
Dr. David McClain
On Jul 3, 2008, at 13:36, Carlos Ungil wrote:
Hi David,
I tried to reply via gmane but I have the impression the message didn't get through, so I'm contacting you directly.
The Mersenne Twister generator is already available in lispworks, see
Cheers,
Carlos