http://qs321.pair.com?node_id=272948


in reply to Can I seed srand() with results from rand()?

While I think that all of the warnings about this scheme eliminating the randomness of rand(), I think that they might be somewhat unwarranted. He is looking for predictability. Also, calling garden variety rand() does not reduce the entropy of the system because garden variety rand() is purely deterministic. So, nothing to worry about there, either.

thor

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

Replies are listed 'Best First'.
Re: Re: Can I seed srand() with results from rand()?
by Anonymous Monk on Jul 11, 2003 at 16:59 UTC
    > 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.

      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.