----- Forwarded message from jcm -----
From jcm Thu May 27 16:09:17 1999
Subject: Better solution to Random>>initializa To: squeak@cs.uiuc.edu (Squeak mailing list) Date: Thu, 27 May 1999 16:09:17 +0200 (METDST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Content-Length: 765
The problem with the initialization of a Random is in the statement:
seed := Time millisecondClockValue * self hash.
which has a problem when self hash evaluates to zero. The solution I propose is to modify that line:
initialize " Set a reasonable Park-Miller starting seed " seed := Time millisecondClockValue * (self hash + 1).
a := 16r000041A7 asFloat. " magic constant = 16807 " m := 16r7FFFFFFF asFloat. " magic constant = 2147483647 " q := (m quo: a) asFloat. r := (m \ a) asFloat.
Greetings, Juan.
PS: I have translated to Squeak the C code to generate random numbers with a normal distribution published in "Numerical Recipes in C", second edition, and implemented the class NormalRandom. Is it legal to publish such code?
----- End of forwarded message from jcm -----
squeak-dev@lists.squeakfoundation.org