Re: Random Seeding
- From: Eric Sosman <Eric.Sosman@xxxxxxx>
- Date: Mon, 15 May 2006 17:18:55 -0400
Keith Thompson wrote On 05/15/06 16:13,:
porterboy76@xxxxxxxxx writes:
(ignores all the possible data after this)?.
this should have read:
(ignores all the possible "starting points" after this)?.
I would suggest that your possibly get 2^32 sequences with 2^19937-1
number of elements in each.
That's kind of what I thought. It seems fairly limited.
However, I just realised the Mersenne Twister c code
provided by it's inventors allows for longer seeds.
"Those who need initial seed with more than 32-bit
length may use init_by_array() for initialization which
admits an array of arbitrary length as seeds"
I guess you could use an array seeded with the time,
the process ID, and some compressed info from
/dev/random or /dev/audio. Still I imagine it would
still be very difficult to guarantee starting points
distibuted uniformly around the ring of numbers?
<OT>
If you have /dev/random, why would you bother with the time, the
process ID, or /dev/audio?
For that matter, if you have /dev/random, it's not entirely clear you
need to bother with a Mersenne Twister (but the question is beyond my
expertise).
</OT>
<OT>
A reproducible seed (and a subsequent reproducible
sequence) can be of value. Consider testing a module by
throwing pseudo-random data at it; when a failure turns
up you'd like to be able to regenerate the exact same data
as part of verifying your fix.
For the second matter, data rate is generally the issue.
It takes a significant amount of time for a physical source
to generate random data and pass it through assorted bias-
removing filters. If you try to read a zillion random numbers
from such a source, you may need to wait quite a while. It's
more common to use /dev/random or whatever to concoct a "truly
random" seed for a deterministic pseudo-random generator that
can generate subsequent numbers at computer speeds. For even
less predictability, the "truly random" source can also be
used to perturb the deterministic generator now and then.
Oddly enough, D.H. Lehmer used something very like this
perturbation technique in his original (and oft-criticized)
linear congruential generator. According to Knuth:
It is not fair to blame Lehmer for using a "bad"
random-number generator in 1948, since his actual
use of the generator was quite valid. The ENIAC
computer was a highly parallel machine, programmed
by means of a plugboard; Lehmer set it up so that
one of its accumulators was repeatedly multiplying
its own contents by 23, mod 10^8+1, yielding a new
value every few microseconds. Since this multiplier
23 is too small, we know that each value obtained
by this process was too strongly related to the
preceding value to be considered sufficiently random;
but the durations of time between actual uses of the
values in the special accumulator by the accompanying
program were comparatively long and subject to some
fluctuation. So the effective multiplier was 23^k
for large, varying values of k!
-- "The Art of Computer Programming, Volume II:
Seminumerical Algorithms," section 3.3.1
Similar techniques can be found nowadays in games, where
it is common to generate and discard a pseudo-random value
each time the program polls its input devices; the eventual
sequence used in the main part of the program thus depends in
part on the delays in keystroke, mouse, or joystick timings,
generally considered unpredictable if not downright twitchy.
</OT>
--
Eric.Sosman@xxxxxxx
.
- Follow-Ups:
- Re: Random Seeding
- From: porterboy76
- Re: Random Seeding
- References:
- Random Seeding
- From: porterboy76
- Re: Random Seeding
- From: rory . brandybuck
- Re: Random Seeding
- From: porterboy76
- Re: Random Seeding
- From: Keith Thompson
- Random Seeding
- Prev by Date: Re: Random Seeding
- Next by Date: Re: short or int
- Previous by thread: Re: Random Seeding
- Next by thread: Re: Random Seeding
- Index(es):
Relevant Pages
|