Kaz Kylheku
1/26/2016 4:14:00 PM
On 2016-01-26, excelemailer@gmail.com <excelemailer@gmail.com> wrote:
> On Tuesday, January 26, 2016 at 7:28:26 AM UTC-8, Jim Newton wrote:
>> Can someone explain to me how to use RANDOM and MAKE-RANDOM-STATE so that
>> every time I run a function the random see starts again at the same point.
>> In my case I want to exercise a function through several hundred random numbers.
>> But when I re-run the function, I want the same sequence of random numbers, and tomorrow
>> when I exit lisp and restart, I still want the same random numbers as yesterday.
>>
>> Is this possible, or do I simply need to generate a list of several 100 random numbers
>> and hard code that list into my program?
>
> Although, I haven't verified whether you get the same randomness from
> one day to the next, (random) appears to use the same seed every time
> without having to configure anything, producing the same results from
> one run to the next. I'm using SBCL.
That's where "one run" means restarting the Lisp image, not calling the
same function.
The PRNG in any darn programming language better have this property as a
default: same sequence unless otherwise seeded.