Simon Peyton-Jones  <[EMAIL PROTECTED]>  wrote on Feb 2 2000:

> The library is currently based on the RandomGen class,
> whose signature is:
> 
>       class RandomGen g wher
>         next :: g  -> (Int, g)
>         split :: g -> (g, g)
> 
> The difficulty is that there is absolutely no robust way to
> use such a generator to generate random numbers uniformly
> distributed in a given range.  Why not?  Because there's no
> clue as to the precise range of Ints produced by next.
> [..]


Fergus Henderson  <[EMAIL PROTECTED]>  replies

H> [..]
H> Wouldn't it be easiest if the RNG just guaranteed to
H> return integers that range over the whole range of `Int'?
H> Note that the range of `Int' can be obtained using the `minBound'
H> and `maxBound' functions in the standard prelude.

Exactly.

|    * The next operation allows one to extract at least 30 bits (one
|      Int's worth) from the generator, returning a new generator as
|      well. The integer returned may be positive or negative.

H> That wording is a little unclear, so I suggest clarifying
H> it as follows:
H>
H>    * The next operation allows one to extract a pseudo-random Int
H>      from the generator, returning a new generator as well.
H>      The integer returned may be positive or negative.
H>      Over a sufficiently large sequence of calls to next,
H>      the integers returned should be uniformly distributed
H>      over the whole range of Int (from minBound to maxBound,
H>      inclusive).
H>
H> If that clarification were made, there would be no need to
H> introduce the `genRange' method that Simon P-J suggested.


Indeed, why not follow this simple approach?

And the line     `The integer returned may be positive or negative.'
can be omitted.
Because it follows from the next sentence.


------------------
Sergey Mechveliani
[EMAIL PROTECTED]


Reply via email to