[Openmcl-devel] weird random problem

Raffael Cavallaro raffaelcavallaro at mac.com
Wed May 21 07:08:59 PDT 2008


On May 21, 2008, at 9:17 AM, p2.edoc at googlemail.com wrote:

> As things stand clean boot (random 100) = 13
> clean boot (random 100) = 13
> so my app booted to start in a completely random state, is in fact  
> repeatable.
> This all seems counter intuitive to me.

from they hyperspec: <http://www.lispworks.com/documentation/HyperSpec/Body/f_mk_rnd.htm 
 >

"One important use of make-random-state is to allow the same series of  
pseudo-random numbers to be generated many times within a single  
program."

Given that this behavior is specifically designed by the spec it is  
the programmer's responsibility to ensure that different runs of  
pseudo-random-numbers are different by the use of make-random-state.

Look at these two clean boot runs in the IDE:

Welcome to Clozure Common Lisp Version 1.2-r9352M-RC1  (DarwinX8664)!
? (defparameter *app-random-state* (make-random-state t))
*APP-RANDOM-STATE*
? (random 100 *app-random-state*)
58
? (random 100 *app-random-state*)
23
? (random 100 *app-random-state*)
74
? (random 100 *app-random-state*)
51
? (random 100 *app-random-state*)
27
?

Welcome to Clozure Common Lisp Version 1.2-r9352M-RC1  (DarwinX8664)!
? (defparameter *app-random-state* (make-random-state t))
*APP-RANDOM-STATE*
? (random 100 *app-random-state*)
90
? (random 100 *app-random-state*)
79
? (random 100 *app-random-state*)
56
? (random 100 *app-random-state*)
52
? (random 100 *app-random-state*)
13
?

regards,

Ralph




Raffael Cavallaro, Ph.D.
raffaelcavallaro at mac.com




More information about the Openmcl-devel mailing list