The stupid question is the question not asked PerlMonks

### Re: Re: Can I seed srand() with results from rand()?

 on Jul 11, 2003 at 16:59 UTC ( #273479=note: print w/replies, xml ) Need Help??

> He is looking for predictability.

There's predictability and there's predictibility. It tends to be bad for simulations if your "random" numbers start being the same on every pass through the main loop.

> Also, calling garden variety rand() does not reduce the entropy of the system because garden variety rand() is purely deterministic.

Entropy measures the number of possible states of a system. Determinism is about the transitions between states. The two concepts are largely orthogonal.

• Comment on Re: Re: Can I seed srand() with results from rand()?

Replies are listed 'Best First'.
Re: Re: Re: Can I seed srand() with results from rand()?
by thor (Priest) on Jul 11, 2003 at 18:55 UTC
There's predictability and there's predictibility. It tends to be bad for simulations if your "random" numbers start being the same on every pass through the main loop.
It all depends on the application. Perhaps you are looking for something in a large set with a certain property. So, rather than iterate through, you pick a random starting point. IIRC, there are non-deterministic primality tests that take a random input and tell you whether a number is composite or not. In this case, you want to keep the one random input that tells you that the number under examination is composite if you want to prove it. If I can find an example of such an algorithm later, I'll update this node.
Entropy measures the number of possible states of a system. Determinism is about the transitions between states. The two concepts are largely orthogonal.
Yes. However, this does not contradict anything that I said. Some people were concerned about repeated calls to rand() reducing the strength of randomness of data received from places like /dev/rand and such. I was saying that this was not the case, as perl uses a PRNG, which given a specific input is completely deterministic.

thor

Update: Check this out.

> Some people were concerned about repeated calls to rand()

I believe the issue was srand().

> I was saying that this was not the case, as perl uses a PRNG, which given a specific input is completely deterministic.

You seem to think that deterministic steps never reduce the entropy of the system. That is not true. Perhaps you meant "reversible"? rand() is commonly reversible, but srand() can't be.

Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://273479]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2022-11-29 00:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My favourite new Perl feature (in 2022) ...

Results (41 votes). Check out past polls.

Notices?