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

Re: [Scheme-reports] No procedure to ask the current time?

On Wed, Sep 01, 2010 at 03:21:48PM -0400, Aubrey Jaffer wrote:
>  | Date: Tue, 31 Aug 2010 09:49:33 -0300
>  | From: Jeronimo Pellegrini <j_p@x>
>  | 
>  | - A PRNG:
>  |   I agree with those that think that including simple randomness
>  |   in "small" Scheme is not encessary, since it's easy to write a
>  |   PRNG that would work fine for didatic purposes: a linear 
>  |   congruential PRNG is trivial to write, easy to understand and
>  |   a nice example of procedure. It's also a nice example of a 
>  |   referentially transparent procedure if you don't hide its
>  |   state -- and later in the course it's possible to talk about
>  |   encapsulation of state using it again as an example.
>  |   However, it would be good to have some way to seed the PRNG
>  |   with a minimally unpredictable number, which could be obtained
>  |   from (time->seconds (current-time))  (for simple randomness
>  |   for students this is usually good enough).
> Linear-congruential PRNGs do not pass Marsaglia's (Diehard) PRNG
> tests.  RC4, which is as easy to write as LCPRNGs and is included in
> SLIB, does pass Diehard
> <http://people.csail.mit.edu/jaffer/slib_5.html#SEC119>.  RC4 does 5
> byte reads, a byte addition, and 5 byte writes per byte of output.
> RC4 effectively computes a cryptographic hash of its key; you can't
> improve on that.

I'd be really happy with that if it's implementable in pure Scheme,
without any extra libraries.

> We do students no favor by getting them accustomed to the flawed PRNGs
> from the twentieth-century

LC PRNGs are good enough for implementing a poker game, for example :-)
One thing that's nice about them is that if the students has learnt some
Algebra, you can actually show them some properties of the PRNG.
But I'm OK with using other PRNG.

Anyway -- we'd still need a seed. :-)


Scheme-reports mailing list