Random number generator question - Unix

This is a discussion on Random number generator question - Unix ; Does anyone know if the values returned by the "random()" function if given the same seed via "srandom()" will be the same on different versions of unix? It seems to be the same for different versions and distributions of linux ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Random number generator question

  1. Random number generator question


    Does anyone know if the values returned by the "random()" function if
    given the same seed via "srandom()" will be the same on different
    versions of unix? It seems to be the same for different versions and
    distributions of linux but I need to be able to reproduce the same
    values on different systems for testing purposes.

    Thanks

    B2003

  2. Re: Random number generator question

    On Sep 24, 3:19*am, Boltar wrote:

    > Does anyone know if the values returned by the "random()" function if
    > given the same seed via "srandom()" will be the same on different
    > versions of unix?


    Maybe, maybe not. You can't rely on it.

    > It seems to be the same for different versions and
    > distributions of linux but I need to be able to reproduce the same
    > values on different systems for testing purposes.


    Then you really need to use your own pseudo random number generator.

    DS

  3. Re: Random number generator question

    David Schwartz writes:

    >On Sep 24, 3:19=A0am, Boltar wrote:


    >> Does anyone know if the values returned by the "random()" function if
    >> given the same seed via "srandom()" will be the same on different
    >> versions of unix?


    >Maybe, maybe not. You can't rely on it.


    >> It seems to be the same for different versions and
    >> distributions of linux but I need to be able to reproduce the same
    >> values on different systems for testing purposes.


    >Then you really need to use your own pseudo random number generator.



    And by "use you own" David probably doesn't mean "write your own".
    Use well recognized PRNGs, such as the Mersenne Twister:

    http://www.math.sci.hiroshima-u.ac.j...at/MT/emt.html

    which produce repeatable outputs across platforms.

    Alternatively, choose a well defined cryptographic hash function, keep
    providing its outputs as its own next inputs, and use as many bits of
    each output as you need.

    --
    Chris.

+ Reply to Thread