[squeak-dev] The Squeak Random Number Generator

John M McIntosh johnmci at smalltalkconsulting.com
Sun Sep 7 07:49:21 UTC 2008


At the time when David N Smith provided it, it replaced a very flawed  
implementation.

 From the comments you can see it's a:
"This Random Number Generator graciously contributed by David N.  
Smith.  It is an adaptation of the Park-Miller RNG which uses Floats  
to avoid the need for LargeInteger arithmetic.:

Normally it would return integers, but as you see it returns floats,  
to avoid the creation and time needed to deal with large integer  
objects.

The theItsCompletelyBrokenTest method returns values that don't match  
for some of the entries due to rounding. Someone with a powerpc  
machine would need
to cross check using an older VM. We altered the current VMs a few  
years back to align floating point rounding rules when it was  
discovered they gave different results on the
platforms for Croquet.


On Sep 7, 2008, at 4:45 AM, Jim Rosenberg wrote:

> I'm getting very queasy feelings about Random.
>
> My understanding of the linear congruence random number generator  
> algorithm is that it depends (crucially) on doing exact integer  
> arithmetic with enough precision to hold all the digits in the  
> multiplication at its heart. Using floating point arithmetic for a  
> linear congruence algorithm is one of the classic ways of  
> implementing a random number generator that is badly flawed.
>
> In my version of Squeak (3.8) the class Random seems to be using  
> floats. Uh oh.
>
> Can somebody comment? Has the Squeak random number generator ever  
> been tested? (Knuth gives a whole raft of tests ...)
>

--
= 
= 
= 
========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
= 
= 
= 
========================================================================





More information about the Squeak-dev mailing list