On 12/06/15 09:15, Michael Titke wrote:

In my understanding the pseudo random number generator is deterministic.
That means for the same input seed /random/ will always return the same
value. This is why one usually has to set a new state for each call of
random.

No, quite on the contrary.

Before going on, please note that I never looked at the specific random generator used by Racket. I assume it's one of the popular random number generator algorithms. For what follows, it doesn't even matter which one.

All pseudorandom generators produce a sequence of numbers. The intention is that the sequence should have as little detectable correlation as possible. The algorithms differ in how they define this goal exactly, and how well they reach it.

The principle behind all these generators is a chaotic dynamic process that transforms the current state of the generator (some finite number of bits) into a new state, which is used for the next call. The returned value is some function of the state. Setting a new seed changes to state to some function of the seed value.

Seeding is provided for two use cases: 1) Reproducibility, mainly for software testing. If you set the seed to some constant at the start of your program, it will behave exactly the same way whenever it is run. 2) "Real" randomization, by setting the seed from some unpredictable source, such as the system time. In both cases, the idea is to set the seed once at the beginning of a program run.

The statistical properties of the pseudo-random sequence hold only for an unperturbed sequence, i.e. without changing the seed. If you set the seed every time you ask for a random number, your random sequence becomes simply some complicated function of your input seed, whose statistical properties are hard to predict and most probably not what you want.

Konrad.

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to