On Dec 3, 9:27 am, Konrad Hinsen <[EMAIL PROTECTED]> wrote:
> I'd provide two interfaces:
>
> 1) Low-level: (rng seed) yielding a pair [random-number, new-seed]
> 2) High-level: (random seed) yielding an infinite (obviously lazy)  
> seq of the random numbers obtained starting from the given seed.
>
> What I consider important is the explicit specification of the seed,  
> which means that the code always says explicitly where its random  
> number sequence starts from.

Some PRNGs make a distinction between "seed" and "state."  For
example, the Mersenne Twister uses one integer as a seed, but an array
of integers as its state, which it modifies each time a new
pseudorandom number is requested.  Of course the "seed" in the sense
of your interface could be that "state" (with the PRNG rewritten to
copy the state before updating it), since the state suffices to
continue the PRNG stream from any particular point.  The MT uses a
rather large amount of state but you lose all the advantages of seqs
and immutability if you don't copy it.

Some parallel PRNGs have two different seeds:  one to guarantee a
unique noncorrelated stream for each processor, and another to seed
the stream.  This isn't much different than your interface, though.

btw (not to you, to another post I recall in this thread) seeding a
PRNG using the thread id isn't enough to guarantee that different
threads don't have correlated PRNG streams.

mfh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to