Mike Gunter sent the following suggestion. I think it's much
the same as Fergus/Tom's.

My conclusion so far: it may be possible, with cunning and
perhaps less efficiency, to do without the genRange method.
But there's a lurking doubt that the cunning might amplify
imperfections in the underlying RNG.  So, while I think we now
agree that (modulo the lurking doubt) it's possible to do without
genRange, I think it's worth adding.  The reasons not to are

        a) it's a change to H98, which should be strongly discouraged

        b) I suppose it's possible that some RNG might not know
                its own range, or the range might change --- but
                in that case I'm even less sure whether the cunning
                tricks would give statistically good results.

Simon

-----Original Message-----
From: Mike Gunter [mailto:[EMAIL PROTECTED]]
Sent: 02 February 2000 18:58
To: Simon Peyton-Jones
Subject: Re: FW: Returned Mail: Recipient no longer with company



> | Hmm.  It would seem to me that you could convert a random generator
> | with a range of 0..N to a generator with a range of L..M with L>=0 and
> | M<=N by just discarding values outside of L..M.  If this is true you
> | could produce 0..10 results from a 0..N generator by taking mod 11 of
> | a 0..J (where J<=N and J = 11n - 1 for some
> | n>=1) generator.
> | 
> | What am I missing?
> 
> (a) you don't know what 0..N is, so you don't know how to choose n
> 
> (b) often 0..N is much much bigger than L..M, so if you call next
>     repeatedly until you get a value in L..M you could wait a long time.

Mapping L..M to 0..(M-L) is easy.  To create a 0..(M-L) generator you
find the largest number j with j == 0 (mod M-L+1) with j <= source
generator's upper bound, UB.  Rejected values can be used to update UB
(with j following).  You can start with UB==0 (or UB== 2^30 -1).
Right?

I have no objection to the proposal.  I just don't understand the
impossibility claim.

                mike

Reply via email to