[mercury-users] random.m: little warning

Peter Ross petdr at cs.mu.OZ.AU
Fri Oct 16 12:02:01 AEST 1998


On 16-Oct-1998, Thomas Charles CONWAY <conway at cs.mu.OZ.AU> wrote:
> Martin Stein, you write:
> > Hi,
> > 
> > The random generator in random.m ran in a cycle of around 60 starting with seed 680380.
> > There are several other seeds with yields in very bad behaviour of my treap, too.
> > (It needs some time to find out that it was "only" the random generator.)
> > 
> > Anyway, are you interested in a hopefully better generator? I implemented one
> > using the Haskell Random.hs as a basis. But I still ought to check it a little.
> 
> I wrote the original one which is a simple linear-congruential generator
> (from Numerical Recipes in C - Press et al). I found it to have poor
> behaviour too. Appended to this mail is a better one - it is much more
> expensive, but is pretty good.
> 
One thing to be aware of when using random number generators is that
they usually expect the size of an integer is a specific number of bits.
(In my very limited experience of copying one out of Numerical Recipies
in C and testing it on a 64 bit machine.)

I can't comment on whether any of the random generators presented here
have this constraint.

However it really does suggest that we add the types int16, int32,
int64 and so on need to be added to the compiler.

Pete.



More information about the users mailing list