Fwd: [plt-scheme] Error in SRFI 27

From: Doug Williams (m.douglas.williams at gmail.com)
Date: Wed Aug 15 08:59:39 EDT 2007

I think I forgot to reply to the list, also.

---------- Forwarded message ----------
From: Doug Williams <m.douglas.williams at gmail.com>
Date: Aug 15, 2007 6:47 AM
Subject: Re: [plt-scheme] Error in SRFI 27
To: Matthew Flatt <mflatt at cs.utah.edu>

In the science collection I wrappered SRFI 27 for random number generation,
provided contracts for the calls, and a added accessors that gave a more PLT
Scheme look-and-feel.  But, I used SRFI 27 for portability - primarily so
other Scheme code could be ported in more easily.  As for speed, faster is
better, but it isn't everything.  The main characteristics I need from SRFI
27 is that it is repeatable - I will get the same sequence of random numbers
by default, but I can randomize the stream when needed.  Both modes are
important for my simulations.
I'm not sure if you are meaning that the implementation would speed up or if
it would slow down if you backported your changes.  But, if SRFI used the
native PLT Scheme random source (or vice versa) [and kept the
characteristics I mentioned above], it might simplify my wrapper to just the


On 8/15/07, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> Does the speed of this random-number generator matter for your
> purposes?
> Long ago, I changed MzScheme's `random' to use the same algorithm, and
> I set things up so that MzScheme's `random' could be used to implement
> SRFI-27. But I never went back to change the SRFI-27 implementation.
> Matthew
> At Tue, 14 Aug 2007 21:08:44 -0600, "Doug Williams" wrote:
> > There seems to have been an error introduced into SRFI 27 sometime late
> in
> > the V370 development leading up to V371.  The random reals generated by
> > 27 all seem to be negative numbers in the range on -1.0e-8 to
> > -1.0e-10instead of 0 to 1.  The following code shows the problem.  In
> > V370 it works
> > properly giving numbers in the range 0.0 to 1.0.  When run under V370.7or
> > V371, it gives the bad numbers.
> >
> > (require (lib "27.ss" "srfi"))
> >
> > (let* ((r (make-random-source))
> >        (rand (random-source-make-reals r)))
> >   (do ((i 0 (+ i 1)))
> >       ((= i 100) (void))
> >     (printf "random real = ~a~n"
> >             (rand))))
> >
> > Doug
> > _________________________________________________
> >   For list-related administrative tasks:
> >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070815/2b6759a4/attachment.html>

Posted on the users mailing list.